[英]Selecting data of a 'person'' using LIMIT from table
I was wondering how to fetch data of a person from a table. 我想知道如何从表中获取一个人的数据。 I found the query to LIMIT
data fetch from table. 我发现查询LIMIT
从表中获取数据。 Here is what I got so far: 这是到目前为止我得到的:
$result = mysql_query("SELECT * FROM users WHERE username = '" . $username[$x] . "' LIMIT " . $last_limt . " , " . $nxt_limt . "");
It returns data when LIMIT
is available but if the LIMIT
exceed the entire data returns null. 当LIMIT
可用时,它将返回数据,但如果LIMIT
超过整个数据,则返回null。 So how can I know if ROW is available or not in table? 那么如何知道表中是否有ROW?
use mysql Count
使用mysql Count
SELECT count(username) FROM users WHERE username ='xyz'
And your $last_limt
is not grater than total count-1
而且您的$last_limt
不比total count-1
You have to check number of rows of the result from that query before proceeding 您必须先检查该查询结果的行数,然后再继续
$result = mysql_query("SELECT * FROM users WHERE username = '" . $username[$x] . "' LIMIT " . $last_limt . " , " . $nxt_limt . "");
$rowcount=mysql_num_rows($result);
if($rowcount > 0)
{
//next operations
}
else
{
//No more data
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.