Welcome to WebmasterWorld Guest from 54.196.107.247

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

formatting array?

formatting an array when select * is used

     
7:58 pm on Jun 30, 2009 (gmt 0)

New User

5+ Year Member

joined:June 24, 2009
posts:27
votes: 0


This is probably an easy answer, but when I use the code below my output is all on one line like
applebananaorangemango

There are only 2 fields on this table, ID and ITEM.
I'd like it to print in this format:
apple
banana
orange
mango


$query = mysql_query("SELECT * FROM menu")
or die (mysql_error());
while ($data = mysql_fetch_array($query, MYSQL_ASSOC))
{
print_r ($data['ITEM']);
}
8:12 pm on June 30, 2009 (gmt 0)

Full Member

10+ Year Member

joined:June 24, 2005
posts:267
votes: 0


instead of:

print_r ($data['ITEM']);

try

echo $data['ITEM']."<br />\r\n";

8:40 pm on June 30, 2009 (gmt 0)

New User

5+ Year Member

joined:June 24, 2009
posts:27
votes: 0


thanks!