★ wanayoo — archive 1999 http://www.php.net/manual/function.mysql-data-seek.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to MySQL
Quick Reference
MySQL
* mysql_affected_rows
* mysql_change_user
* mysql_close
* mysql_connect
* mysql_create_db
* mysql_data_seek
* mysql_db_query
* mysql_drop_db
* mysql_errno
* mysql_error
* mysql_fetch_array
* mysql_fetch_field
* mysql_fetch_lengths
* mysql_fetch_object
* mysql_fetch_row
* mysql_field_name
* mysql_field_seek
* mysql_field_table
* mysql_field_type
* mysql_field_flags
* mysql_field_len
* mysql_free_result
* mysql_insert_id
* mysql_list_fields
* mysql_list_dbs
* mysql_list_tables
* mysql_num_fields
* mysql_num_rows
* mysql_pconnect
* mysql_query
* mysql_result
* mysql_select_db
* mysql_tablename
Manual: mysql_data_seek
View the source code for this pageSearch the site



Previous page
 mysql_create_db
mysql_db_query 
Next page


mysql_data_seek

(PHP3 , PHP4 )

mysql_data_seek -- Move internal result pointer

Description

int mysql_data_seek (int result_identifier, int row_number)

Returns: true on success, false on failure.

mysql_data_seek() moves the internal row pointer of the MySQL result associated with the specified result identifier to point to the specified row number. The next call to mysql_fetch_row() would return that row.

Row_number starts at 0.

Example 1. MySQL data seek example

  1 
  2 <?php
  3     $link = mysql_pconnect ("kron", "jutta", "geheim") {
  4         or die ("Could not connect");
  5     }
  6 
  7     mysql_select_db ("samp_db") {
  8         or die ("Could not select database");
  9     }
 10 
 11     $query = "SELECT last_name, first_name FROM friends";
 12     $result = mysql_query ($query) {
 13         or die ("Query failed");
 14     }
 15 
 16     # fetch rows in reverse order
 17 
 18     for ($i = mysql_num_rows ($result) - 1; $i >=0; $i--) {
 19         if (!mysql_data_seek ($result, $i)) {
 20             printf ("Cannot seek to row %d\n", $i);
 21             continue;
 22         }
 23 
 24         if(!($row = mysql_fetch_object ($result)))
 25             continue;
 26 
 27         printf ("%s %s<BR>\n", $row->last_name, $row->first_name);
 28     }
 29 
 30     mysql_free_result ($result);
 31 ?>
 32      

User Contributed Notes: mysql_data_seek


info@lsm.de
29-Apr-2000 11:42
using mysql data seek is working fine to set the pointer to a row. But how is it possible to ask the other way around on which record i am on? Alex


 About Notes


Previous page
 mysql_create_db
mysql_db_query 
Next page



Site Statistics


Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.