hey i want to use php mysql_fetch_array to fetch full table data at a time for that i use
while($user_details_result[]=mysql_fetch_assoc($user_details_qr));
but it returns a blank array at last like below
output:
Array
(
[0] => Array
(
[user_id] => 2
[user_name] => w
[user_login_id] => w
[user_login_password] => w
[user_contacts] => w
[user_status] => 0
[user_post_date] => ::1
[user_post_ip] => 2014-03-07 16:17:59
)
[1] => Array
(
[user_id] => 1
[user_name] => q
[user_login_id] => q
[user_login_password] => q
[user_contacts] => q
[user_status] => 1
[user_post_date] => ::1
[user_post_ip] => 2014-03-07 16:14:23
)
[2] =>
)
i dont understand why 3 rd row appears..please help
Use this
while($temp=mysql_fetch_assoc($user_details_qr)) {
user_details_result[] = $temp;
}
mysql_fetch_assoc
will return FALSE
if there is no more row in the resultset. If you write FALSE
into $user_details_result[]
, that will become a blank array.
http://us1.php.net/manual/function.mysql-fetch-assoc.php
Try this
while($cur_row=mysql_fetch_assoc($user_details_qr)) {
if($cur_row !== FALSE) { $user_details_result[] = $cur_row; }
}
But I think it should even work without the if
, just like this (test it):
while($cur_row=mysql_fetch_assoc($user_details_qr)) {
$user_details_result[] = $cur_row;
}
try using like this
while($row=mysql_fetch_assoc($user_details_qr))
{
if (count($row) > 0)
$user_details_result[] = $row;
}
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.