Recently in one of my project i wrote the following code for retrieving and print data from database.
$query = "select * from tblteachers limit 0, 4";
$result= mysql_query($query) or die(mysql_error());
if(mysql_num_rows($result)>0)
{
while($fetchRow=mysql_fetch_array($result, MYSQL_BOTH))
{
echo $fetchRow['id'];
}
}
in the tblteachers table there are 14 row and the query get 4 row but the problem is it print 3 row by missing the first row. that is it print 2, 3, 4.
you might have used something that moved the pointer. try adding mysql_data_seek($result,0); before the while statement
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.