forumnz Posted June 7, 2008 Share Posted June 7, 2008 I want to SELECT numbers FROM a database WHERE user='user'...I know how to do that... but lets say there is 5 rows with that user... how can I display the number from each one like this 1,2,3,4,5 ? Just the numbers with a comma in between? Hope this makes sense! Thanks! Sam. Link to comment https://forums.phpfreaks.com/topic/109093-solved-displaying-numbers-from-rows-in-db/ Share on other sites More sharing options...
digitalgod Posted June 7, 2008 Share Posted June 7, 2008 $query = "SELECT...."; $result = mysql_query($query) or die(mysql_error()); while( $row = mysql_fetch_array($result) ) { echo $row['columnname']; } Link to comment https://forums.phpfreaks.com/topic/109093-solved-displaying-numbers-from-rows-in-db/#findComment-559649 Share on other sites More sharing options...
forumnz Posted June 7, 2008 Author Share Posted June 7, 2008 Thanks..but what if I want it to be a variable? Like if in the end I want $numbers to equal '1,2,3,4,5'. How is that done? Link to comment https://forums.phpfreaks.com/topic/109093-solved-displaying-numbers-from-rows-in-db/#findComment-559652 Share on other sites More sharing options...
digitalgod Posted June 7, 2008 Share Posted June 7, 2008 I'm not sure I understand what you mean, what columns are you selecting and what is it that you want to be displayed? Link to comment https://forums.phpfreaks.com/topic/109093-solved-displaying-numbers-from-rows-in-db/#findComment-559653 Share on other sites More sharing options...
sasa Posted June 7, 2008 Share Posted June 7, 2008 $query = "SELECT...."; $result = mysql_query($query) or die(mysql_error()); while( $row = mysql_fetch_array($result) ) { $num[] = $row['columnname']; } $numbers = implode(',', $num); Link to comment https://forums.phpfreaks.com/topic/109093-solved-displaying-numbers-from-rows-in-db/#findComment-559655 Share on other sites More sharing options...
digitalgod Posted June 7, 2008 Share Posted June 7, 2008 oh snap... I really am tired so yeah what sasa said should do the trick Link to comment https://forums.phpfreaks.com/topic/109093-solved-displaying-numbers-from-rows-in-db/#findComment-559656 Share on other sites More sharing options...
forumnz Posted June 7, 2008 Author Share Posted June 7, 2008 Thanks everyone! Link to comment https://forums.phpfreaks.com/topic/109093-solved-displaying-numbers-from-rows-in-db/#findComment-559659 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.