Jump to content

[SOLVED] add mysql_query results into new arrays


kredd

Recommended Posts

hello all, i'm selecting 'photos' and 'thumbnails' from my table and need to get all returned info into two separate arrays. i'm still new to how the process of retreiving and displaying mysql data works ( a tad different from asp )...

 

the code below is pretty straighforward. pretty easy to see what i'm trying to do and also how wrong it is  ;D  i'll also need to do this for a couple other fields (photo captions and photo credits) so i was also wondering if putting everything into its own array is the most efficient method. basically the i'll count the size of the thumbs array and use a for loop to itterate $i and then use $i to display all corresponding info based on which thumbnail they rollover - thumbnail array[$i], big photo array[$i], photo captions array[$i], etc..

 

any ideas?

 

while($row = mysql_fetch_array( $result )) {

// get all thumbs in gallery
$thumbs = array();
	foreach ($row['thumbnail'] as $files){
		array_push($thumbs, $files);

	}

// get all bigs in gallery
$bigs = array();
	foreach ($row['photo'] as $bfiles){
		array_push($bigs, $bfiles);
	}
}


} // end while looop

 

thanks!

Link to comment
Share on other sites

<?php
$thumbs = array();
$bigs = array();
while($row = mysql_fetch_array( $result )) {
	array_push($thumbs, $row['thumbnail']);
        	array_push($bigs, $row['photo']);
}

echo '<pre>',print_r($thumbs),print_r($bigs),'</pre>';
?>

 

Like that?

Link to comment
Share on other sites

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.