<?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.20 $ --> <refentry id="function.mysqli-data-seek"> <refnamediv> <refname>mysqli_data_seek</refname> <refname>result->data_seek()</refname> <refpurpose>Adjusts the result pointer to an arbitary row in the result</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <para>Procedural style:</para> <methodsynopsis> <type>bool</type><methodname>mysqli_data_seek</methodname> <methodparam><type>mysqli_result</type><parameter>result</parameter></methodparam> <methodparam><type>int</type><parameter>offset</parameter></methodparam> </methodsynopsis> <para>Object oriented style (method):</para> <classsynopsis> <ooclass><classname>mysqli_result</classname></ooclass> <methodsynopsis> <type>bool</type><methodname>data_seek</methodname> <methodparam><type>int</type><parameter>offset</parameter></methodparam> </methodsynopsis> </classsynopsis> <para> The <function>mysqli_data_seek</function> function seeks to an arbitrary result pointer specified by the <parameter>offset</parameter> in the result set. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> &mysqli.result.description; <varlistentry> <term><parameter>offset</parameter></term> <listitem> <para> The field offset. Must be between zero and the total number of rows minus one (0..<function>mysqli_num_rows</function> - 1). </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &return.success; </para> </refsect1> <refsect1 role="notes"> &reftitle.notes; <note> <para> This function can only be used with buffered results attained from the use of the <function>mysqli_store_result</function> or <function>mysqli_query</function> functions. </para> </note> </refsect1> <refsect1 role="examples"> &reftitle.examples; <example> <title>Object oriented style</title> <programlisting role="php"> <![CDATA[ <?php /* Open a connection */ $mysqli = new mysqli("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $query = "SELECT Name, CountryCode FROM City ORDER BY Name"; if ($result = $mysqli->query( $query)) { /* seek to row no. 400 */ $result->data_seek(399); /* fetch row */ $row = $result->fetch_row(); printf ("City: %s Countrycode: %s\n", $row[0], $row[1]); /* free result set*/ $result->close(); } /* close connection */ $mysqli->close(); ?> ]]> </programlisting> </example> <example> <title>Procedural style</title> <programlisting role="php"> <![CDATA[ <?php /* Open a connection */ $link = mysqli_connect("localhost", "my_user", "my_password", "world"); /* check connection */ if (!$link) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $query = "SELECT Name, CountryCode FROM City ORDER BY Name"; if ($result = mysqli_query($link, $query)) { /* seek to row no. 400 */ mysqli_data_seek($result, 399); /* fetch row */ $row = mysqli_fetch_row($result); printf ("City: %s Countrycode: %s\n", $row[0], $row[1]); /* free result set*/ mysqli_free_result($result); } /* close connection */ mysqli_close($link); ?> ]]> </programlisting> </example> &example.outputs; <screen> <![CDATA[ City: Benin City Countrycode: NGA ]]> </screen> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>mysqli_store_result</function></member> <member><function>mysqli_fetch_row</function></member> <member><function>mysqli_fetch_array</function></member> <member><function>mysqli_fetch_assoc</function></member> <member><function>mysqli_fetch_object</function></member> <member><function>mysqli_query</function></member> <member><function>mysqli_num_rows</function></member> </simplelist> </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 -->