|
I am getting undefined variable when I open my page?
This code is from a book that I am using to learn PHP. This same code works on my search form but not my data entry page. I am trying to put a select box on my data entry page.
$connection = mysql_connect('localhost','sctwest','kermit') or die(mysql_error());
$table_name = "assignto_tbl";
$assign = "SELECT Distinct assignTo FROM $table_name ORDER BY assignTo";
$result = mysql_query($assign,$connection) or die(mysql_error());
$num = mysql_num_rows($result);
if ($num < 1) {
$display_block = "<p><em>Sorry! No Results.</em></p>";
} else {
while ($row = mysql_fetch_array($result)) {
//$_id = $row['_id'];
$assignTo = $row['assignTo'];
$option_block .= "<option value=\"$assignTo\">$assignTo</option>";
$display_block = "
<FORM METHOD=\"POST\" ACTION=\"FOIA_dataentry_frm.php\">
<p><strong>assignTo:</strong>
<select name =\"assignTo\">
$option_block
</select>
<INPUT TYPE=\"SUBMIT\" NAME=\"submit\" VALUE=\"Select this Name\"></p>
</form>";
}
This is the part of my HTML that is giving me the errors. I get undifined variable $display_block when I open this page even though it is defined above.
<tr>
<td>
Assigned To:
<?php echo "$display_block"; ?>
Received CAO:
<input name="recvd_cao" size="10">
Rose Boyd Review:
<input name="rb_review" size="10">
</td>
</tr>
THANKS!
|