Jump to content

[SOLVED] Multiple Records SELECTED how do I access individual records, and columns?


TGWSE_GY

Recommended Posts

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  :-\

	//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 :-\

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.