Coded Firstimage Coded Firstimage - 5 months ago 18
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

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"); 
$num=mysql_num_rows($query2); 
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"];
    $password=$info["password"]; 
    print_r($info);
  }
} 

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