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] Link to comment https://forums.phpfreaks.com/topic/34068-query-question/ 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? Link to comment https://forums.phpfreaks.com/topic/34068-query-question/#findComment-160147 Share on other sites More sharing options...
corillo181 Posted January 14, 2007 Author Share Posted January 14, 2007 thank you my friend// Link to comment https://forums.phpfreaks.com/topic/34068-query-question/#findComment-160157 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 ;) Link to comment https://forums.phpfreaks.com/topic/34068-query-question/#findComment-160158 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. Link to comment https://forums.phpfreaks.com/topic/34068-query-question/#findComment-160188 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. Link to comment https://forums.phpfreaks.com/topic/34068-query-question/#findComment-160192 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 Link to comment https://forums.phpfreaks.com/topic/34068-query-question/#findComment-160197 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? Link to comment https://forums.phpfreaks.com/topic/34068-query-question/#findComment-160198 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. Link to comment https://forums.phpfreaks.com/topic/34068-query-question/#findComment-160370 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.