rofl90 Posted March 28, 2008 Share Posted March 28, 2008 I'm creating a filing system for my news management, but when somebody picks more than one it will loop 'cat1, cat2, cat3,' How do I get the last one to go 'cat4' Thx Link to comment https://forums.phpfreaks.com/topic/98267-news-filing/ Share on other sites More sharing options...
benjaminbeazy Posted March 28, 2008 Share Posted March 28, 2008 please provide better explanation and/or code Link to comment https://forums.phpfreaks.com/topic/98267-news-filing/#findComment-502804 Share on other sites More sharing options...
rofl90 Posted March 28, 2008 Author Share Posted March 28, 2008 eg: while($row = mysql_fetch_array($result)) { echo $row['category']; echo ", "; } If theres say, 3 categories chosen i want it to display as cat1, cat2, cat3. But it displays as cat1, cat2, cat3, Link to comment https://forums.phpfreaks.com/topic/98267-news-filing/#findComment-502807 Share on other sites More sharing options...
cooldude832 Posted March 28, 2008 Share Posted March 28, 2008 are you talking about the trailing comma? the trick to this is <?php $q_count = mysql_num_rows($result); $i = 1; while($row = mysql_fetch_array($result)) { echo $row['category']; if($i < $q_count){ echo ", "; } $i++; } ?> Link to comment https://forums.phpfreaks.com/topic/98267-news-filing/#findComment-502810 Share on other sites More sharing options...
rofl90 Posted March 28, 2008 Author Share Posted March 28, 2008 Ahh, why didn't I think of that, thankyou Link to comment https://forums.phpfreaks.com/topic/98267-news-filing/#findComment-502812 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.