• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 683
  • Last Modified:

mysql_data_seek is returning an Extra Empty row

Hello,

I am using mysql_data_seek to do multiple loops, the problem is that it is returning an extra blank row....

so the first time it loops, i get 3 results, after i use mysql_data_seek and loop again I get 4 results with the first being empty, this is the code...
$query_Recordset_get_menu_java_cat = "SELECT * FROM product_cat ORDER BY product_cat_name ASC";
$Recordset_get_menu_java_cat = mysql_query($query_Recordset_get_menu_java_cat, $mine) or die(mysql_error());
$row_Recordset_get_menu_java_cat = mysql_fetch_assoc($Recordset_get_menu_java_cat);
$totalRows_Recordset_get_menu_java_cat = mysql_num_rows($Recordset_get_menu_java_cat);


<?php do { // this gets 3 results - perfect  ?>

Product Cat DIV <?php echo $row_Recordset_get_menu_java_cat['product_cat_id']; ?>


<?php  } while ($row_Recordset_get_menu_java_cat = mysql_fetch_assoc($Recordset_get_menu_java_cat)); ?>



<?php 
mysql_data_seek($Recordset_get_menu_java_cat, 0);
do { // this gets 4 results - 1st one empty ?>

Product Cat DIV <?php echo $row_Recordset_get_menu_java_cat['product_cat_id']; ?>


<?php  } while ($row_Recordset_get_menu_java_cat = mysql_fetch_assoc($Recordset_get_menu_java_cat)); ?>

Open in new window

0
jblayney
Asked:
jblayney
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
please change your loops into:


<?php
//mysql_data_seek($Recordset_get_menu_java_cat, 0);
while ($row_Recordset_get_menu_java_cat = mysql_fetch_assoc($Recordset_get_menu_java_cat))
{  ?>

Product Cat DIV <?php echo $row_Recordset_get_menu_java_cat['product_cat_id']; ?>

<?php  }  ?>
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now