I have this loop which generates selects:
$loops=7;
//for($j=1;$j<=$loops;$j++){
foreach($_SESSION['product'] as $key=>$val){
$quantity = 7;
$selqty = '<div class="optchk"><select name="qty[]" class="qty">';
for($i=1;$i<=$quantity;$i++){
$selqty.='<option value="'.$i.'">'.$i.'</option>';
}
$selqty.='</select></div>';
}
echo '<form method="post" action="" name="orderform">';
echo $selqty;
echo '<input type="submit" name="order_submit" value="Send"></form>';
How to keep each selected option for all those 7 selects after form submit? Thank you
post looks like :
array(7) {
[0]=> string(1) "2"
[1]=> string(1) "3"
[2]=> string(1) "4"
[3]=> string(1) "4"
[4]=> string(1) "2"
[5]=> string(1) "3"
[6]=> string(1) "4"
}
and I tried the following :
<?php if($_POST['qty'] =$i) $selected= 'selected=selected';
$selqty.='<option '.$selected.' value="'.$i.'">'.$i.'</option>';
?>
but it is wrong