I’ve got a problem with my php script. The script generates two <ul>‘s, one with the images, another with the thumbnails. The php runs through the first while loop perfectly, but my <ul> for thumbnails always comes back empty. I’ve been working through it to no luck, and I can’t seem to get the script to print any errors. Help?
include "../backend/connect.php";
$query = "select image_id from images where thumb != '';";
$result = mysql_query($query);
<div id="main">
<div id="container">
<ul>
<?php
while ($row = mysql_fetch_array($result)) {
$img_id = $row['image_id'];
?>
<li class="hidden" id="<?php print($img_id); ?>" style="background-image:url(/pull.php?id=<?php print($img_id);?>&thumb=false)"></li>
<?php } ?>
<li class="" id="focus"></li>
</ul>
</div>
</div>
<div id="side">
<div id="photos"><ul>
<?php
while ($row = mysql_fetch_array($result)) {
$img_id = $row['image_id'];
?>
<div class="imgDiv" id="<?php print($img_id); ?>" >
<li>
<img src="pull.php?id=<?php print($img_id);?>&thumb=true" class="thumbnail"/>
</li>
</div>
<?php
}
?>
</ul></div>
</div>
</div>
you’re using a while loop to loop through the results, you cant do it twice.
Call
mysql_data_seek($result, 0);to reset the internal pointer back to the first record after your first time through the results to start over.