corillo181 Posted January 14, 2007 Share Posted January 14, 2007 why isn't this working?i know i would make it work if i just putting with out array but i want to do it with array[code]<?php$mns=mysql_query("select name from tra_music_song")or die(mysql_error());while($names=mysql_fetch_array($mns)){$arran=array($names['name'])echo $arran;?>[/code] Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 14, 2007 Share Posted January 14, 2007 print_r($arran);Is that what you mean? Quote Link to comment Share on other sites More sharing options...
corillo181 Posted January 14, 2007 Author Share Posted January 14, 2007 thank you my friend// Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 14, 2007 Share Posted January 14, 2007 If you want it to look nice, add [code]<pre>[/code] in front ;) Quote Link to comment Share on other sites More sharing options...
corillo181 Posted January 14, 2007 Author Share Posted January 14, 2007 when i use this code i get [code]<?php$mns=mysql_query("select name from tra_music_song")or die(mysql_error());while($names=mysql_fetch_array($mns)){$arran=array($names['name']);print_r($arran);}?>[/code]this result[code]Array ( [0] => El Champion ) Array ( [0] => Un Segundo ) Array ( [0] => Bonside )[/code]and i want this result[code]Array ( [0] => El Champion, [1] => Un Segundo, [2] => Bonside )[/code]like a normal array outcome. Quote Link to comment Share on other sites More sharing options...
zachmorelikezack Posted January 14, 2007 Share Posted January 14, 2007 Create the array before the while loop and use array_push() to fill in the values.[code]<?php$mns=mysql_query("select name from tra_music_song")or die(mysql_error());$arran = array();while($names=mysql_fetch_array($mns)){array_push($arran, $names['name']);}print_r($arran);?>[/code]I'm pretty sure that will work, but I haven't used it in a while and could be wrong. I know that array_push is what you need. If that doesn't work, check out php.net and look up array_push. Quote Link to comment Share on other sites More sharing options...
corillo181 Posted January 14, 2007 Author Share Posted January 14, 2007 i dont know how to get that to work Quote Link to comment Share on other sites More sharing options...
zachmorelikezack Posted January 14, 2007 Share Posted January 14, 2007 That should work. I looked up some of my older code and found basically the exact same usage. What is it displaying when you run it through? Quote Link to comment Share on other sites More sharing options...
corillo181 Posted January 14, 2007 Author Share Posted January 14, 2007 not getting anything becuase i dont know how to applay the code..try going to php.net but couldn't understand it very well. Quote Link to comment 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.