I have deleted the only user that gets found and now no-one can be found. I don't think it is a problem with the code, but here it is:
<PRE><?
// script to query inventory based on user-entered text strings
// connection information
$hostName = "localhost";
$userName = "username";
$password = "password";
$dbName = "sim";
// make connection to database
mysql_connect($hostName, $userName, $password) or die( "Unable to connect to host $hostName");
mysql_select_db($dbName) or die( "Unable to select database $dbName");
// Select all the fields in the sim table for
// records that match the form entries
$query = "SELECT * FROM sim WHERE User = '$Usersname' ORDER BY User";
$result = mysql_query($query);
// Determine the number of rows
$number = mysql_numrows($result);
if ($number == 0) {
print "Sorry, no SIM cards have been sent to <B>$Usersname</B>. Is the spelling correct?<P><a href='javascript:history.back()'><< Back</a>";
} else {
print "<B>There are $number matching records in the inventory:</b><p>
<table cellpadding=5 border=1 bordercolor='#000000'>
<tr bgcolor=black>
<td><font color=white><b>User Name</b></td>
<td><font color=white><b>Payroll</b></td>
<td><font color=white><b>Remedy</b></td>
<td><font color=white><b>SIM Number</b></td>
<td><font color=white><b>Date Sent</b></td>
<td><font color=white><b>Address</b></td>
<td><font color=white><b>Senders Name</b></td>
<td><font color=white><b>Fault Description</b></td>
<td><font color=white><b>SIM ID</b></td></tr>";
// Print the results
for($i=0; $i<$number; $i++){
$User = mysql_result($result,$i, "User");
$Payroll = mysql_result($result,$i, "Payroll");
$Remedy = mysql_result($result, $i, "Remedy");
$Details = mysql_result($result, $i, "Details");
$SimNumber = mysql_result($result, $i, "SimNumber");
$DateSent = mysql_result($result, $i, "DateSent");
$Address1 = mysql_result($result, $i, "Address1");
$Address2 = mysql_result($result, $i, "Address2");
$Address3 = mysql_result($result, $i, "Address3");
$Postcode = mysql_result($result, $i, "Postcode");
$AgentName = mysql_result($result, $i, "AgentName");
$id = mysql_result($result, $i, "id");
/ print even-numbered rows with a grey background,
odd-numbered with a white background /
if ($i%2 == 0) {
print "<tr bgcolor=lightgrey>";
} else {
print "<tr>";
}
print "<td>$User</td>
<td>$Payroll</td>
<td>$Remedy</td>
<td>$SimNumber</td>
<td>$DateSent</td>
<td>$Address1<BR>$Address2<BR>$Address3 $Postcode</td>
<td>$AgentName</td>
<td>$Details</td>
<td align='center'>$id</td></tr>";
}
print "</table>";
}
// Close the database connection
mysql_close();
?></PRE>