I have this code that I am trying to model from a previous class assignment. The very first part declares a short variable but I am not sure why it is not working. Any ideas?
<?php
if(isset($_POST['in_Person_id'])){ $in_Person_id = $_POST['in_Person_id']
?>
<html>
<head>
<title>Person_Select.php</title>
</head>
<body>
<h1>Guest System</h1>
<?php
@ $db = new mysqli('localhost', 'hrbailey' , 'hb1628', 'hrbailey');
if (mysqli_connect_errno())
{
echo 'Error: Could not connect to database. Please try again later.';
exit;
}
$query = "select * from person
where person_id = '$in_Person_id' ";
echo $query;
$result= @mysqli_query ($db, $query);
$num_results = mysqli_num_rows($result);
if ( $num_results == 0)
{
echo '<font color=red>';
echo 'No Person data found. <br />';
echo '</font>';
echo '<p><a href="Person_Menu.html">Return to Menu</a> </p>';
}
else
{
echo ' <br> <br> ';
echo 'Your search found ';
echo $num_results;
echo ' matches';
echo ' <br> <br> <br>';
//Build Table Header
echo'<table align="center" cellspacing="3" cellpadding="3" width="75%">
<tr>
<td align="left"> <b> Person_id </b> </td>
<td align="left"> <b> Last name </b> </td>
<td align="left"> <b> First Name </b> </td>
<td align="left"> <b> Street Address </b> </td>
<td align="left"> <b> City </b> </td>
<td align="left"> <b> State </b> </td>
<td align="left"> <b> Zip </b> </td>
<td align="left"> <b> RSVP </b> </td>
<td align="left"> <b> Hotel </b> </td>
<td align="left"> <b> Household </b> </td>
<td align="left"> <b> Gift </b> </td>
</tr>';
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
{
echo '<tr>
<td align="left">' .$row['person_id']. '</td>
<td align="left">' .$row['Last Name']. '</td>
<td align="left">' .$row['description']. '</td>
<td align="left">' .$row['First Name']. '</td>
<td align="left">' .$row['Street Address']. '</td>
<td align="left">' .$row['City']. '</td>
<td align="left">' .$row['State']. '</td>
<td align="left">' .$row['Zip']. '</td>
<td align="left">' .$row['RSVP']. '</td>
<td align="left">' .$row['Hotel']. '</td>
<td align="left">' .$row['Household']. '</td>
<td align="left">' .$row['Gift']. '</td>
<td align="left"> <a href=Person_RSVP.php?person='
.$row['person_id'].
'&prod=' .$row['person_id']. '>View Guests </a> </td>
</tr>';
}
echo '</table>';
echo '<br />';
echo '<p><a href="Person_Menu.html">Return to Menu</a> </p>';
}
$result->free();
$db->close();
?>
</body>
</html>
Update: I am getting these notices and warnings:
Notice: Undefined index: in_Person_id in C:\student\hrbailey\Person_Select.php on line 3
Guest System
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\student\hrbailey\Person_Select.php on line 30
No Person data found. Return to Menu
Fatal error: Call to a member function free() on a non-object in C:\student\hrbailey\Person_Select.php on line 90