Easiest way is to pull all the data your going to need out into an array of arrays, then just re-use the array later. consider the following example:
you have a table of images, each image has a number of attributes with it like so...
image_name,image_width,image_height,image_depth,image_author
ok, so you construct the appropriate SQL stament etc, and that gives you a loop where you go over your "mysql_fetch_array" call, somthing like:
while ( $row1 = mysql_fetch_array($query) )
{
$name = $row1['image_name'];
print ($name);
print ('<br />');
}
Rather than printing the image name there and then, just push them all into an array of arrays, EG:
$image_list = array()
while ( $row1 = mysql_fetch_array($query) )
{
$this_image = array();
$this_image['name'] = $row1['image_name'];
$this_image['height'] = $row1['image_height'];
$this_image['width'] = $row1['image_width'];
$this_image['depth'] = $row1['image_depth'];
$this_image['author'] = $row1['image_author'];
$image_list[] = $this_image;
}
What you'll then end up with is an array that looks like this:
[0]----------------->[name]
[0]----------------->[height]
[0]----------------->[width]
[0]----------------->[depth]
[0]----------------->[author]
[1]----------------->[name]
[1]----------------->[height]
[1]----------------->[width]
[1]----------------->[depth]
[1]----------------->[author]
[2]----------------->[name]
[2]----------------->[height]
[2]----------------->[width]
[2]----------------->[depth]
[2]----------------->[author]
so say, at a later point, if you wanted only the name of image 2, you could simply say:
echo $image_list[2]['name'] . "<br/>";
or you can loop over all of them as follows:
foreach($image_list as $image)
{
echo $image['name'];
}
Then later on, go back and print different values:
foreach($image_list as $image)
{
echo $image['author'];
}
As long as your script doesn't end, the data will stay in memory and you can just jump back and forth in the root array to your hearts content using a number index.