dtyson2000 Posted July 23, 2006 Share Posted July 23, 2006 Hi Folks...I'm going nuts with this implode function. I just need to list a distinct group of cities pulled from a database as a comma separated list with no comma after the last city. So I have been playing with this and the best I can do is get it to list each city name twice. Can you see something that I'm missing?while ($row= mysql_fetch_array($result)){ $city=mysql_result($result,$i,"city"); echo implode(', ', $row); $i++;}Thanks, in advance! Quote Link to comment https://forums.phpfreaks.com/topic/15413-going-crazy-over-implode/ Share on other sites More sharing options...
448191 Posted July 23, 2006 Share Posted July 23, 2006 Use [i]mysql_fetch_assoc()[/i] or [i]mysql_fetch_array($result,MYSQL_ASSOC)[/i]To elaborate:[b]mysql_fetch_array [/b] ( resource result [, [u][i]int result_type[/i][/u]] )[i]result_type[/i]The type of array that is to be fetched. It's a constant and can take the following values: MYSQL_ASSOC, MYSQL_NUM, [u]and the default value of MYSQL_BOTH[/u]. Leaving "result_type" will return values twice; once with numeric, once with associative keys. Quote Link to comment https://forums.phpfreaks.com/topic/15413-going-crazy-over-implode/#findComment-62477 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.