dvayne Posted April 27, 2008 Share Posted April 27, 2008 here's the table messages username message1 name1 message2 name2 message3 name2 message4 name1 message5 name3 I want to display like this.. name1 message1 message4 name2 message2 message3 name3 message5 please help me.. Quote Link to comment https://forums.phpfreaks.com/topic/103112-displaying-by-group/ Share on other sites More sharing options...
sasa Posted April 27, 2008 Share Posted April 27, 2008 try <?php // conect to db $result = mysql_query('SELECT * FROM table-name ORDER BY username'); $row = mysql_fetch_array($result); echo $row['username'],'<br />'; $name = $row['username']; do{ if($row['username'] != $name){ echo $row['username'],'<br />'; $name = $row['username']; } echo $row['messages'],'<br />'; } while ($row = mysql_fetch_array($result)) ?> Quote Link to comment https://forums.phpfreaks.com/topic/103112-displaying-by-group/#findComment-528186 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.