mysql_data_seek和mysql_field_seek之间的区别?

时间:2013-04-26 17:46:15

标签: php mysql database

我发现他们两个都在做同样的工作。有没有差别。我想,我错过了什么。

mysql_data_seek

<?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>";
?>

mysql_field_seek

<?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)
?>

1 个答案:

答案 0 :(得分:1)

mysql_data_seek - moves to a specific row of the dataset
mysql_field_seek - moves to a specific column of current row of the dataset

实际上是您问题的答案is in the same page from which you copied this question