Coded Firstimage Coded Firstimage - 2 years ago 77
PHP Question

I want to get all rows in mysql

I want to fetch all rows in mysql but it returns only 1. I have tried this out:

while($info=mysql_fetch_all($query2, mysql_assoc))

but it is not working. Please help me out.

Answer Source

Quick fix is to replace mysql_fetch_all to mysql_fetch_assoc:

$query2=mysql_query("SELECT * FROM websitee 
  WHERE poster='$_SESSION[user_name]' 
  ORDER BY id DESC LIMIT $offset, $rowsperpage"); 
if($num==0) { 
  echo"<div class='msg'>No topics yet</div>"; 
} else { 
  echo"<br/><br/><div align='center' class='b_head'><strong>HOTTEST UPDATES</strong></div><div class='center'><span class='style18'></span></div><br><br> ";
  while($info=mysql_fetch_assoc ($query2)) { 
    $id=$info["id"]; $ftp=$info["ftp"]; $server=$info["server"];

But you should stop using mysql_* functions and use mysqli or pdo.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download