Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Always one record short

Status
Not open for further replies.

brk1221

MIS
Jan 29, 2002
230
US
Hi, the results of my SELECT on my .php page always returns one record short. It displays "There are 3 records." but only 2 will display. (I've verified there are accually 3 records) I've included the code from the .php file: thank you

if ($code=="")
$sql = ("SELECT * FROM sites WHERE state='$state'");
elseif ($state=="")
$sql = ("SELECT * FROM sites WHERE code='$code'");
else
$sql = ("SELECT * FROM sites WHERE code='$code' AND state='$state'");
//echo($sql);
$result = mysql_query($sql);
if ($myrow = mysql_fetch_array($result))
$num_rows = mysql_num_rows($result);
print &quot;<p><a href=javascript:history.back(1)><font size=1>BACK</font></a></p>&quot;;
print &quot;There are $num_rows records.<P>&quot;;

print &quot;<table width=100% border=1>\n&quot;;
while ($get_info = mysql_fetch_row($result)){
print &quot;<tr>\n&quot;;
foreach ($get_info as $field)
print &quot;\t<td> <font face=arial size=1/>$field</font></td>\n&quot;;
print &quot;</tr>\n&quot;;
}
print &quot;</table>\n&quot;;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top