I'm not a PHP programmer, but I'm trying to learn it.
The problem with the above code is that nothing happens when the user forgets to select a radio button for the trKeys field. The form submits and goes to the next page (select.php) where it returns an error because the value of trKeys was null.
All help is much appreciated.
Code:
<?PHP
include "config.php";
include "opendb.php";
$query="select trKey, trStartText, trWho, trType from training";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
?>
<table border = 1 cellpadding =10 align = "center"><tr><td align = "center"><font size = '4'>Select<br>This Slot</font></td><td><font size = '4'>Time Slot</td><td><font size='4'>Who</font></td><td><font size='4'>Needs Help With</font></td></tr>
<!-- Start of FORM -->
<form method="POST" action="select.php">
<input type=hidden name="required_fields" value="trKeys">
<?
$i=0;
while ($i < $num) {
$trkey=mysql_result($result, $i, "trkey");
$slot=mysql_result($result, $i, "trStartText");
$who=mysql_result($result,$i,"trWho");
$helpwith=mysql_result($result,$i,"trType");
echo "<tr><td><input type='radio' name='trKeys' value='$trkey'></td><td valign = 'top'>$slot</td><td valign = 'top'>$who </td><td>$helpwith </td></tr>";
$i++;
}
?>
<tr><Td> </td><td colspan = 3><input type="Submit" value="Submit"></td></tr>
</form>
<!-- End of FORM -->
The problem with the above code is that nothing happens when the user forgets to select a radio button for the trKeys field. The form submits and goes to the next page (select.php) where it returns an error because the value of trKeys was null.
All help is much appreciated.