Returning last value in loop
Posted: Wed Jul 16, 2008 6:46 pm
I have a table in the database with a column with the following values
v_number
12345
54321
789
When I loop through this with the code below using the from field it seems to just return the last value 789 as ‘is valid’ but not the others.
Why is this not returning ‘Valid’ when I submit the other correct values?
I know there are security issues with this from but I’m just working on the basics to get this working before adding the security.
Thanks
v_number
12345
54321
789
When I loop through this with the code below using the from field it seems to just return the last value 789 as ‘is valid’ but not the others.
Why is this not returning ‘Valid’ when I submit the other correct values?
I know there are security issues with this from but I’m just working on the basics to get this working before adding the security.
Thanks
Code: Select all
// run loop to see if submitted voucher exists.
if ($_POST && array_key_exists('MM_update',$_POST)) {
do {
if (isset($_POST['v_number_1']) && ($_POST['v_number_1']) == $row_GetVouchers['v_number']) {
// if it does not exist then point that out
$number = 'is valid ';
}else{
$number = '<strong> Not valid </strong>';
}
} while ($row_GetVouchers = mysql_fetch_assoc($GetVouchers));
}
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
Voucher 1:
<?php if (isset($number) && !empty($number)) {
echo $number ; } ?>
<input type="text" name="v_number_1" value="<?php if (isset($_POST['v_number_1'])) echo $_POST['v_number_1'];?>" size="32">
<input type="submit" value="Apply Vouchers">
<input type="hidden" name="MM_update" value="form1">
</form>