PDA

View Full Version : Moving to next row


Cacus
10-24-2006, 11:46 PM
Hi all

I have the following bit of code:

<?php
$query_related = "SELECT * FROM photographs WHERE city_town='$citytown'ORDER BY RAND() LIMIT 5";
$result_related = mysql_query($query_related);
$row_related = mysql_fetch_array($result_related);
?>

Related photogaphs

<div id="relatedphotos_container">
<div id="relatedphotos_pic1"><img src="thumbnails/<?php echo $row_related['image_ref'] ?>_thumb.jpg" alt=""/></div>
<div id="relatedphotos_pic2"><img src="thumbnails/<?php echo $row_related['image_ref'] ?>_thumb.jpg" alt=""/></div>
<div id="relatedphotos_pic3"><img src="thumbnails/<?php echo $row_related['image_ref'] ?>_thumb.jpg" alt=""/></div>
<div id="relatedphotos_pic4"><img src="thumbnails/<?php echo $row_related['image_ref'] ?>_thumb.jpg" alt=""/></div>
<div id="relatedphotos_pic5"><img src="thumbnails/<?php echo $row_related['image_ref'] ?>_thumb.jpg" alt=""/></div>
</div>

I need to be able to advance (manually) through each of the five results so that a different pic appears in each div. I figure (being a novice) that i could put mysql_next_result() between each pic div but that didn't work. Incidently $citytown is defined else were in the page. And the aim is to call 5 thumbnail pictures into separate div's that relate to the main picture ($citytown)

Any help would be appreciated
Cacus

Brandoe85
10-25-2006, 12:08 AM
You could do it with mysql_result();
http://us2.php.net/mysql_result

Good luck;

GJay
10-25-2006, 08:55 AM
or by using mysql_fetch_array($result_related) again.
As well as returning the array, it advances the recordset so that subsequent calls to the function return subsequent rows.

Cacus
10-25-2006, 09:23 PM
Thanks guys.

Just the job!

Steve