PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

mysql_field_table> <mysql_field_name
Last updated: Mon, 26 Nov 2007

view this page in

mysql_field_seek

(PHP 4, PHP 5, PECL mysql:1.0)

mysql_field_seek — 将结果集中的指针设定为制定的字段偏移量

说明

int mysql_field_seek ( resource $result , int $field_offset )

用指定的字段偏移量检索。如果下一个 mysql_fetch_field() 的调用不包括字段偏移量,则会返回本次 mysql_field_seek() 中指定的偏移量的字段。

参见 mysql_fetch_field()



mysql_field_table> <mysql_field_name
Last updated: Mon, 26 Nov 2007
 
add a note add a note User Contributed Notes
mysql_field_seek
chris at igwsolutions dot com
26-Apr-2008 06:23
I spent a good deal of time trying to get the example to work, but the example does not work.
To do what the exaple is trying to do, you would need to use mysql_data_seek

assume we have table named testing which contains
id      name
1       Hassan
2       Jack
3       Rose
---------------

Here is an expample that will do the above example.

Since I am more comfortable in a OOP setting, I used mysql_fetch_object

<?php
   
require("myConnenctionFile.php");
   
   
$sql="SELECT  * from testing";
   
$result=mysql_query($sql);

   
$row = mysql_fetch_object($result);
    echo
$row->id . ' ' . $row->name; // Output is (1      Hassan)
   
mysql_data_seek($result,2);
   
$row = mysql_fetch_object($result);
    echo
$row->id . ' ' . $row->name; // Output is (3      Rose)
   
echo "<BR><BR>";
?>
Hassan Kazem
11-Jan-2008 02:34
an example of this function
assume we have table1 which contains
ID      Name
1       Hassan
2       Jack
3       Rose
---------------
<?php
mysql_connect
("sql.server.com", "username", "password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
$sql="SELECT  * from table1";
$result=mysql_query($sql);
$row = mysql_fetch_array($result);
echo
$row['ID'] . ' ' . $row['Name']; // Output is (1      Hassan)
mysql_field_seek($result,2);
echo
$row['ID'] . ' ' . $row['Name']; // Output is (3      Rose)
?>
---------------
// You can see that the seek command forwarded the pointer one step and skipped row number 2
poulpillusion at free dot fr
17-Apr-2007 10:44
A dumb comment... but it may save people some time :
mysql_field_seek != mysql_data_seek

In order to fetch again the results of a resource result from the beginning, you will use mysql_data_seek(id, 0)

mysql_field_table> <mysql_field_name
Last updated: Mon, 26 Nov 2007
 
 
show source | credits | sitemap | contact | advertising | mirror sites