TGWSE_GY Posted April 29, 2009 Share Posted April 29, 2009 Hi Guys, What I am attempting do is grab multiple records and putting all those records into a multidimensional array. I was thinking simply by saying $GetPhotos = mysql_query("SELECT * FROM profile_user_images WHERE CustID = '$CustID'"); $FetchArray = mysql_fetch_array($GetPhotos); And then I could treat it as a multi dimensional array and call for items like this $FetchArray["1"]["ImageName"] However when I echo the above statement I get nothing in return, what am I doing wrong or can I not put the records into a multidimensional array?> Thanks Guys :-\ Link to comment https://forums.phpfreaks.com/topic/156069-solved-multiple-records-selected-how-do-i-access-individual-records-and-columns/ Share on other sites More sharing options...
Mchl Posted April 29, 2009 Share Posted April 29, 2009 See example #2 on manual entry for mysql_query Link to comment https://forums.phpfreaks.com/topic/156069-solved-multiple-records-selected-how-do-i-access-individual-records-and-columns/#findComment-821614 Share on other sites More sharing options...
TGWSE_GY Posted April 29, 2009 Author Share Posted April 29, 2009 //Get users Photos $GetPhotos = mysql_query("SELECT * FROM profile_user_images WHERE CustID = '$CustID'"); if (mysql_num_rows($GetPhotos) > 0) { //Fetching the db records and putting them into an array $FecthArray = mysql_fetch_array($GetPhotos); //Get number of records in $FetchArray $TotalRecords = mysql_num_rows($GetPhotos); echo $TotalRecords; //Initialize the counter $I = 1; //Initialize and process the data in $FetchArray while displaying the results to the browser for viewer interaction while ($row = mysql_fetch_assoc($GetPhotos)) { echo $row['ImageType']; echo $row['ImageName']; } die(); Okay so the while loop returns nothing but $TotalRecords returns 1 so I know the record is there but its not retrieving the data for some reason. Any ideas? Thanks :-\ Link to comment https://forums.phpfreaks.com/topic/156069-solved-multiple-records-selected-how-do-i-access-individual-records-and-columns/#findComment-821924 Share on other sites More sharing options...
Mchl Posted April 29, 2009 Share Posted April 29, 2009 You're calling mysql_fetch_array once before while loop. IF the query returns one row only, there are no more to loop through. Remove this line $FecthArray = mysql_fetch_array($GetPhotos); and see what happens. Link to comment https://forums.phpfreaks.com/topic/156069-solved-multiple-records-selected-how-do-i-access-individual-records-and-columns/#findComment-821932 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.