i have this SQL code :
$sql="SELECT * FROM functions
WHERE user_name='ben '
AND (function_description LIKE '%xxx%') ";
it give me back two lines on phpmyadmin SQL :
user_name function_type function_name function_description
ben PHP PHP1 that xxx
ben PHP PHP2 lofaif adnan xxx i
but when i tried to echo back those lines using this :
$results=mysql_query($sql,$connection);
while($row=mysql_fetch_array($results, MYSQL_ASSOC))
{
echo $row['function_name'] . " : " . $row['function_description'] . "<br/><br/>";
}
it give me back just this :
PHP2:lofaif adnan xxx i
and i want to echo back the 2 lines .. whats the problem with it ?
The
whileloop you are currently in will only print out the current iteration. To print out all rows in the DB simply initialise the$rowsvariable as an array$rows = array();and assign all the rows to it viawhile($rows[]=mysql_fetch_array($results, MYSQL_ASSOC)). Your$rowsvariable should now contain all the DB records.