I have a PHP loop that contains a query within the loop I set two variables to contain certain results, I then want to use the variables outside of the loop. However when I do they just return as undefined. The code is as follows:
<?php
$standardresult = mssql_query("SELECT Price FROM Extras WHERE ExtraID = 5 ");
while ($standardrow = mssql_fetch_array($standardresult )) {
$toughresult = mssql_query("SELECT Price FROM Extras WHERE ExtraID = 6 ");
while ($toughrow = mssql_fetch_array($toughresult)) {
$toughprice = $toughrow['Price'];
$standardprice = $standardrow['Price'];
echo $standardrow['Price'];
echo $toughrow['Price'];
?>
<td align="center">
<input type="radio" name="triple" value="yes" onclick="showPrice('<?php echo $standardrow['Price']; ?>','<?php echo $toughrow['Price']; ?>')" /> yes
</td>
<td> </td>
<td align="center">
<input type="radio" name="triple" value="no" onclick="showPrice('0','0')" checked="checked" /> no
</td>
<?php
}
}
?>
</tr>
</table>
<input type="hidden" name="ToughPrice" value="<?php echo $toughprice; ?>" />
<input type="hidden" name="StanPrice" value="<?php echo $standardprice; ?>" />
the variables in question are $toughprice and $standardprice. Can anyone tell me where I am going wrong, or if its possible please? Thank you for any help.
??? i guess it should be
maybe it will make a difference …