homepage Welcome to WebmasterWorld Guest from 54.163.139.36
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
formatting array?
formatting an array when select * is used
reffik024

5+ Year Member



 
Msg#: 3943456 posted 7:58 pm on Jun 30, 2009 (gmt 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']);
}

 

mooger35

5+ Year Member



 
Msg#: 3943456 posted 8:12 pm on Jun 30, 2009 (gmt 0)

instead of:

print_r ($data['ITEM']);

try

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

reffik024

5+ Year Member



 
Msg#: 3943456 posted 8:40 pm on Jun 30, 2009 (gmt 0)

thanks!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved