lilman Posted November 20, 2006 Share Posted November 20, 2006 My objective: I have a SELECT query that will select rows from a table in my database. I would like to put the results from the query into a numeric array (I am thinking it is going to need to be a multidimensional array). The array needs to store the column values, maybe it would look something like this:$users = array( "1"=>array // auto increment ( "$id", // column from database "$path", // column from database "$score", // column from database ),"2"=>array // auto increment ( "$id", // column from database "$path", // column from database "$score", // column from database ),); My hurtle: I am not sure how to put my results in an array like the one above (if that is even the best way to do this).If someone could help me out that would be terrific, thank you Link to comment https://forums.phpfreaks.com/topic/27817-retrieving-results-from-mysql-inserting-into-array/ Share on other sites More sharing options...
Stooney Posted November 20, 2006 Share Posted November 20, 2006 do you plan to output all the information immediately?if so you could:[code]$query=@mysql_query("select id, path, score from table");while($row=mysql_fetch_array($query)){ echo $row[0]; //id echo $row[1]; //path echo $row[2]; //score}[/code]the while will loop until it reaches the end of the array, aka all the users. Link to comment https://forums.phpfreaks.com/topic/27817-retrieving-results-from-mysql-inserting-into-array/#findComment-127288 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.