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!

<?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?

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.