For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > March 2006 > Displaying results from a query properly.









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Displaying results from a query properly.
Alex Major

2006-03-24, 7:00 pm

Hi there.
This isn't a major problem, more of a matter of aesthetics.
Basically, I have a query which pulls a list of usernames from the database
(based on their user level).

These users should then listed in this fashion.

Administrators: allydm, alex, mike, dave
Moderators: big 'd', frank, william

However, the loop that I have returns the results like this...

Administrators: allydm, alex, mike, dave,
Moderators: big 'd', frank, william,

There is a , after each username, including the last one in that list. I'm
after a way of making the usernames display with a , after them, apart from
the last username in that set of results.

My current display code is:

<?php
do {echo ''.$administrators['username'].', ';}
while ($administrators = mysql_fetch_assoc($administrators_result
))
?>

How could I change to display the results in the fashion that I'd like?
Many thanks for any suggestions.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com