Jump to content


going crazy over "implode"

  • Please log in to reply
1 reply to this topic

#1 dtyson2000

  • Members
  • PipPipPip
  • Advanced Member
  • 93 posts

Posted 23 July 2006 - 07:48 PM

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)){
echo implode(', ', $row);

Thanks, in advance!

#2 448191

  • Staff Alumni
  • Advanced Member
  • 3,545 posts
  • LocationNetherlands

Posted 23 July 2006 - 07:55 PM

Use mysql_fetch_assoc() or mysql_fetch_array($result,MYSQL_ASSOC)

To elaborate:
mysql_fetch_array ( resource result [, int result_type] )

The type of array that is to be fetched. It's a constant and can take the following values: MYSQL_ASSOC, MYSQL_NUM, and the default value of MYSQL_BOTH.

Leaving "result_type" will return values twice; once with numeric, once with associative keys.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users