php - Update multiple select box -
i have code :
<?php if($_get["id"]){ $rezizmjena = mysqli_query($kon, "select * shops id=". $_get["id"] ." limit 1"); $redizmjena = mysqli_fetch_assoc($rezizmjena); $fototxt = "nieuwe logo :"; $btntxt = "veranderen"; }else{ $fototxt = "kies logo :"; $btntxt = "toevoegen"; } ?> <div class="col-xs-12 col-sm-5"> <select class="form-control" name="slcregio[]" multiple="multiple"> <?php $rez = mysqli_query($kon, "select * regios"); echo "<option selected disabled>kies een regio</option>"; while($red = mysqli_fetch_assoc($rez)){ $rez1 = mysqli_query($kon, "select regios.id, shop_regio_tt.regio_id, shop_regio_tt.shop_id regios inner join shop_regio_tt on regios.id = shop_regio_tt.regio_id"); while($red1 = mysqli_fetch_assoc($rez1)){ if($red1["shop_regio_tt.shop_id"] == $redizmjena["id"]){ $selected = "selected"; }else{ $selected = ""; } } echo "<option value=\"". $red["id"] ."\" ". $selected .">". $red["naam"] ."</option>"; } ?> </select><br /> </div>
in database have shops table (id, naam, ...), regios table (id, naam) , shop_regio_tt (id, shop_id, regio_id).
when want update item want see items have been selected. code nothing selected.
i fetch result here
foreach ($_post["slcregio"] $regio_id){ mysqli_query($kon, "insert shop_regio_tt values(null,". $_post["izmjena"] .",". $regio_id .")"); }
and how update shop_regio_tt if hidden field has been send?
thanks in advance.
yes in code snippest there
if($red1["shop_regio_tt.shop_id"] == $redizmjena["id"])
i did not found variable $redizmjena.
i think should $red['id']
Comments
Post a Comment