kredd Posted May 31, 2007 Share Posted May 31, 2007 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 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! Quote Link to comment Share on other sites More sharing options...
per1os Posted May 31, 2007 Share Posted May 31, 2007 <?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? Quote Link to comment Share on other sites More sharing options...
kredd Posted May 31, 2007 Author Share Posted May 31, 2007 perfecto! thanks man...so obvious after you posted Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.