Home >Backend Development >PHP Tutorial >PHP determines whether mysql has reached the end of the record_PHP tutorial

PHP determines whether mysql has reached the end of the record_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:51:291100browse




End of file

Excuse me, after I query the data table. Send a query statement to determine whether it is the end of the file. If it is not the end of the file, run the "conditional" while ($result != EOF). This sentence seems wrong? How should I write it?
$sql="select * from table1";
$result=mysql_query($sql);
while($result != EOF)
{
Conditions
}


Help little brother. . Studying! !

Let me answer




D8888D reply content------------------------------------------------- ----------
while($row = mysql_fetch_array($result,MYSQL_ASSOC)){
print_r($row);
}

D8888D reply content------------------------------------------------- ----------
I want to determine the end of the file. If it is not the end of file then run the condition. Is it OK to change it to this?
$sql="select * from table1";
$result=mysql_query($sql);
$row=mysql_fetch_array($result,MYSQL_ASSOC);
while ($row!=false)
{
Conditions
}

D8888D reply content------------------------------------------------- ----------
Is it the end of the file or array traversal. . . I'm dizzy

D8888D reply content------------------------------------------------- ----------
I am also confused. I want to query the data table and then determine whether it is the end of the file. If it is not the end of the file, run the condition. If it is the end of the file, break out of the loop. How to do this? [img]http://www.111cn.cn/bbs/images/smilies/default/sweat.gif[/img]
$result=mysql_query($sql);
$row=mysql_fetch_array($result,MYSQL_ASSOC);
while ($row!=false)
{
$nowdt=$CustRs["ac_exp_dt"];
$nowmon=$CustRs["ac_exp_mon"];
$nowyr=$CustRs["ac_exp_year"];
$daydiff=(strtotime(date("$nowyr"."-"."$nowmon"."-"."$nowdt")) - strtotime(date("Y-m-d")))/86400;
if ($daydiff else
{mysql_query("UPDATE CUSTOMERS SET Current_Status=1 where indexuid="$CustRS["indexuid"]"");}
}

D8888D reply content------------------------------------------------- ----------
e....I don't understand your concept: end of file
Does your database query have anything to do with files?

D8888D reply content------------------------------------------------- ----------
echo mysql_data_seek (mysql_num_rows($sql) -1, $db_resource_link);


Copy code

D8888D reply content------------------------------------------------- ----------
It is a one-word shortcut to update all records. Update one by one until the end of the record.

D8888D reply content------------------------------------------------- ----------
Original post by loveyou_85 on 2009-3-6 17:22 [url=http://bbs.111cn.cn/redirect.php?goto=findpost&pid=896058&ptid=107381]Link tag [img]http://bbs. 111cn.cn/images/common/back.gif[/img][/url]
It is a one-word shortcut to update all records. Update one by one until the end of the record.
sweat. . You don’t directly talk about stack operations

D8888D reply content------------------------------------------------- ----------
How to write boss????


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632545.htmlTechArticleExcuse me at the end of the file. I am checking the data table. Send a query statement to determine whether it is the end of the file. If it is not the end of the file, run the "conditional" while($result != EOF). This sentence seems wrong...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn