Have you ever wondered why you can't reuse a recordset after it has been displayed in a repeat region?
The answer is quite simple once you realize that a repeat region is simply a do... while loop that iterates (goes one by one) through the database result. When it gets to the end of the loop, there's nothing left to display. However, that doesn't mean you need to create a duplicate recordset to access the same data again.
When going through the loop, PHP uses an internal pointer so that it knows which record is currently being displayed. When it gets to the end of the repeat region, the pointer is left at the end of the database result. All you need to do is to reset the pointer back to the beginning of the recordset.
This is how you do it (in the following code, replace recordsetName with the actual name of your own recordset):
<?php // reset the recordset after a repeat region mysql_data_seek($recordsetName, 0); // get the first row from the recordset $row_recordsetName = mysql_fetch_assoc($recordsetName); ?>
You can now use the recordset again. The second command gets the first record from the recordset ready for use.
Although you can use the Bindings panel to insert dynamic text objects into your page, Dreamweaver won't let you apply a second repeat region server behavior to a recordset once it has been used. It doesn't recognize that the recordset has been reset. No problem.
If you want to use exactly the same repeat region, just copy it and paste it into the new location, making sure that the reset code comes between the two repeat regions.
If you want to use the recordset in a different way, it's very easy to hand code the repeat region (again replace recordsetName with the actual name of your recordset):
<?php do { ?>
Put what you want to repeat here
<?php } while ($row_recordsetName = mysql_fetch_assoc($recordsetName)); ?>
That's all there is to it!

This work is licensed under a
Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License