Jump to content

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


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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.