Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL Recordset While Loop Problem

Status
Not open for further replies.

WilliamMute

Programmer
Jan 4, 2006
117
Hello everyone, I have a question please and am wondering if anyone can lend a helping hand. I am querying a MySQL database for records, storing them in a recordset.

THE PROBLEM:

When am displaying the recordset, it seems to be displaying each record twice in other words it seem like it going through the while loop twice. here is my code please.


<table width="100%"> There are currently <?php echo "$total_records"; ?> found Bracelets

<?php
while($row_Recordset1 = mysql_fetch_assoc($Recordset1) ) { ?>


<tr>
<td class="SubHeadings" colspan="3">Bracelets - </td>
</tr>


<tr class="LoopRowsQuery"><p>
<td width="173" align="center" class="LoopRowsQuery"><p><a href="gift.php"><img src="<?php echo "products/". $row_Recordset1['image']; ?>.jpg" alt="Gift Ideas" width="102" height="118" border="0" align="absbottom" class="RightTablesImges"></a></p></td>

<td width="173" align="center" class="LoopRowsQuery"><p><a href="gift.php"><?php echo $row_Recordset1['product_name']; ?></a></p></td>

<td width="173" align="center" class="LoopRowsQuery"><p><a href="gift.php">£<?php echo $row_Recordset1['product_price']; ?></a></p>
</td>

</tr>
<tr>
<td height="10">&nbsp; </td>
</tr>
<tr>
<td class="SubHeadings" colspan="3">Bracelets - </td>
</tr>

<tr class="LoopRowsQuery2">
<td width="173" align="center" class="LoopRowsQuery2"><p><a href="gift.php"><img src="<?php echo "products/". $row_Recordset1['image']; ?>.jpg" alt="Gift Ideas" width="102" height="118" border="0" align="absbottom" class="RightTablesImges"></a></p></td>

<td width="173" align="center" class="LoopRowsQuery2"><p><a href="gift.php"><?php echo $row_Recordset1['product_name']; ?></a></p></td>

<td width="173" align="center" class="LoopRowsQuery2"><p><a href="gift.php">£<?php echo $row_Recordset1['product_price']; ?></a></p></td>
</tr>

<tr>
<td height="10">&nbsp; </td>
</tr>


<?php

}

?>



Any Help is much appreciated. If you could also render help towards displaying say 10 records at a time with link of pages at the bottom for next and previous page great, because I have been on that for a few days as well read so many articles but yet no luck.

Cheers
 
Hello,

I notice that when I remove one of the <tr> within the while statement, I dont have the problem of dublication of a row anymore.

The reason I had two <tr> which might seem strange was to change the colour of every other row <tr> so i.e

<tr color="white">

next <tr color="red">

so where you have 20 rows of data, you will have red, white red white etc. I dont know if there is an easier way of doing that pls.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top