mysql_data_seek is returning an Extra Empty row

Posted on 2010-01-05
Last Modified: 2013-12-13

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)); ?>


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

Question by:jblayney
    1 Comment
    LVL 142

    Accepted Solution

    please change your loops into:

    //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  }  ?>

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now