   #PHP Manual Improved MySQL Extension mysqli_connect mysqli_debug

   PHP Manual
   Prev  Next
   ______________________________________________________________________

                               mysqli_data_seek

   (PHP 5 CVS only)
   mysqli_data_seek -- Adjusts the result pointer to an arbitrary row in
   the result

Description

   void mysqli_data_seek ( resource result, int offset)

   The mysqli_data_seek() function seeks to an arbitrary result pointer
   specified by the offset in the result set represented by result. The
   offset parameter must be between zero and the total number of rows
   minus one (0..mysqli_num_rows() - 1).

     Note: This function can only be used with results attained from the
     use of the mysqli_store_result() function.

   Example 1. Using the mysqli_data_seek function
   <?php


       /* Open a connection */
       $link = mysqli_connect("localhost", "username", "password");
       mysqli_select_db("mydb");


       /* Get some rows and store them */
       $query = "SELECT DINSTINCT name FROM employee ORDER BY name";
       $result = mysqli_query($query) or die(mysqli_error());
       $rows = mysqli_store_result($result);
       $total = mysqli_num_fields($rows);
       if ($total > 0) { // there is at least one row
           /* Get the last employee */
           mysqli_data_seek($rows, mysqli_num_rows($result) -1);
           $employee = mysqli_fetch_row($rows);
           printf("Employee name : %s\n", $employee[0]);
       }

       mysqli_free_result($rows);
   ?>

   See also mysqli_store_result(), mysqli_fetch_row() and
   mysqli_num_rows().
   ______________________________________________________________________

   Prev           Home         Next
   mysqli_connect  Up  mysqli_debug
