Sessions Problem!
Posted: Tue Feb 03, 2009 12:28 pm
Hello i am doing sessions in a project and i have one of my variables working with it but for some reason my other one isnt heres my code.
my quantity value is appearing all right but my windowtype only appears all the time "Bow Windows" even when it isnt.
much appreciated for any help given, i think its only a small problem.
Code: Select all
<label> Bow Windows </label>
<div id="box24"><input type="text" name="quantity[]" size="1"selected="selected"> <label> Quantity</label></div>
<div id="box25"><img src="FYP/img19.jpg" alt="Windows"/>
<label> Bay Windows </label>
</div>
<div id="box26"><input type="text" name="quantity[]" size="1" selected="selected"><label> Quantity</label></div>
<div id="box27"><img src="FYP/img20.jpg" alt="Windows"/>
<label> Speciality Type Windows </label>
</div>
<div id="box28"><input type="text" name="quantity[]" size="1" selected="selected"><label> Quantity</label></div>
<div id="box29"><img src="FYP/img21.jpg" alt="Windows"/>
<label value="windowtype[2]"> Vertical Slider Windows</label>
</div>
<div id="box30"><input type="text" name="quantity[]" size="1" selected="selected"><label> Quantity</label></div>
<div id="box31"><img src="FYP/img22.jpg" alt="Windows"/>
<label> Casement Windows </label>
</div>
<div id="box32"><input type="text" name="quantity[]" size="1" selected="selected"><label> Quantity</label></div>
<div id="box33"><img src="FYP/img23.jpg" alt="Windows"/>
<label> Tilt and Turn Windows </label>
</div>
<div id="box34"><input type="text" name="quantity[]" size="1" selected="selected"><label> Quantity</label></div>
<div id="box38">
<input type="submit" value="Continue to Customer Details"/>
</div>
[color=#404000]<INPUT TYPE="hidden" name="windowtype[0]" VALUE="Bow Windows">[/color]
<INPUT TYPE="hidden" name="windowtype[1]" VALUE="Bay Windows">
<INPUT TYPE="hidden" name="windowtype[2]" VALUE="Speciality Type Windows">
<INPUT TYPE="hidden" name="windowtype[3]" VALUE="Vertical Slider Windows">
<INPUT TYPE="hidden" name="windowtype[4]" VALUE="Casement Windows">
<INPUT TYPE="hidden" name="windowtype[5]" VALUE="Tilt and Turn Windows">
</div>
</div>
Code: Select all
<?php
$qt = $_POST['quantity'];
$wt = $_POST['windowtype'];
$_SESSION['windowtype'] = array();
$_SESSION['quantity'] = array();
$i = 0;
foreach($qt as $a)
{
if($a[$i])
{
$_SESSION['windowtype'][$i] = $wt[$i];
$_SESSION['quantity'][$i] = $a[i];
$i ++;
}
}
?>
// my following pagemy quantity value is appearing all right but my windowtype only appears all the time "Bow Windows" even when it isnt.
much appreciated for any help given, i think its only a small problem.