<?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.5 $ --> <!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 --> <refentry id="function.mysql-data-seek"> <refnamediv> <refname>mysql_data_seek</refname> <refpurpose>Move internal result pointer</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>bool</type><methodname>mysql_data_seek</methodname> <methodparam><type>resource</type><parameter>result_identifier</parameter></methodparam> <methodparam><type>int</type><parameter>row_number</parameter></methodparam> </methodsynopsis> <para> &return.success; </para> <para> <function>mysql_data_seek</function> 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 <function>mysql_fetch_row</function> would return that row. </para> <para> <parameter>Row_number</parameter> starts at 0. The <parameter> row_number</parameter> should be a value in the range from 0 to mysql_num_rows - 1. </para> <note> <para> The function <function>mysql_data_seek</function> can be used in conjunction only with <function>mysql_query</function>, not with <function>mysql_unbuffered_query</function>. </para> </note> <example> <title>MySQL data seek example</title> <programlisting role="php"> <![CDATA[ <?php $link = mysql_pconnect("localhost", "mysql_user", "mysql_password") or die("Could not connect: " . mysql_error()); mysql_select_db("samp_db") or die("Could not select database: " . mysql_error()); $query = "SELECT last_name, first_name FROM friends"; $result = mysql_query($query) or die("Query failed: " . mysql_error()); /* fetch rows in reverse order */ for ($i = mysql_num_rows($result) - 1; $i >= 0; $i--) { if (!mysql_data_seek($result, $i)) { echo "Cannot seek to row $i: " . mysql_error() . "\n"; continue; } if(!($row = mysql_fetch_object($result))) continue; echo "$row->last_name $row->first_name<br />\n"; } mysql_free_result($result); ?> ]]> </programlisting> </example> <para> See also: <function>mysql_query</function>, <function>mysql_num_rows</function>. </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->