i am working on php and using mySQL with it. I have a table named "images" which contains 2 columns named "user_id" and "name". 5 rows are filled.Example of table is below:
User_id ---Name
1 waterfall
1 mountain
2 wind
2 sunset
2 snowfall
I am using the script which print all result line by line(i.e 5 results).I want the result which should print 2 results,for example :
1 waterfall
2 wind
it should print unique "user_id" only once with its related "name". and it can increase as the database increase.I am pasting the script which i used, please help :( and correct my script.Thanks in advance.:)
$query = "SELECT * FROM images WHERE user_id>0 ORDER BY user_id DESC LIMIT $offset, $limit";
$result = mysql_query($query);
//This is the start of the normal results...
while ($row = mysql_fetch_array($result))
{
$img_name=$row['name'];
$user_id=$row['user_id'];
echo $img_name."<br>";
echo $user_id."<br>";
echo "<br>";
}
mysql_close();