php-doc-en/reference/mysqli/functions/mysqli-data-seek.xml
Mehdi Achour 6b2dd02515 some more ws, thanks alindeman
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@128734 c90b9560-bf6c-de11-be94-00142212c4b1
2003-05-25 19:27:11 +00:00

88 lines
2.8 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.6 $ -->
<refentry id="function.mysqli-data-seek">
<refnamediv>
<refname>mysqli_data_seek</refname>
<refpurpose>Adjusts the result pointer to an arbitary row in the result</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>void</type><methodname>mysqli_data_seek</methodname>
<methodparam><type>resource</type><parameter>result</parameter></methodparam>
<methodparam><type>int</type><parameter>offset</parameter></methodparam>
</methodsynopsis>
<para>
The <function>mysqli_data_seek</function> function seeks to an arbitrary result pointer
specified by the <parameter>offset</parameter> in the result set represented by
<parameter>result</parameter>. The <parameter>offset</parameter> parameter must be between
zero and the total number of rows minus one (0..<function>mysqli_num_rows</function> - 1).
</para>
<note>
<para>
This function can only be used with results attained from the use of the
<function>mysqli_store_result</function> function.
</para>
</note>
<para>
<example>
<title>Using the mysqli_data_seek function</title>
<programlisting role="php">
<![CDATA[
<?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);
?>
]]>
</programlisting>
</example>
</para>
<para>
See also
<function>mysqli_store_result</function>,
<function>mysqli_fetch_row</function> and
<function>mysqli_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
-->