好象MYSQL_DATA_SEEK只是移动到字段呀,不是移动到记录

解决方案 »

  1.   

    <?
    include "mysql_result_all.php";
    $conn = mysql_connect();
    mysql_select_db("test");
    $rs = mysql_query("select * from test1");
    mysql_result_all($rs); //结果1
    mysql_data_seek($rs,4); //移动指针
    mysql_result_all($rs); //结果2
    ?>
    结果1
    name nume rq 
    add,sdfa,13 1 00000000000000 
    4ad,adfww,23 2 00000000000000 
    asd32,sd,21 3 00000000000000 
    ad,se,422 4 00000000000000 
    4 5 00000000000000 
    5 6 00000000000000 
    6 7 00000000000000 
    aaa  00000000000000 
    aaa 2 20030515135144 
      20030515135202 
    12  00000000000000 
    结果2
    name nume rq 
    4 5 00000000000000 
    5 6 00000000000000 
    6 7 00000000000000 
    aaa  00000000000000 
    aaa 2 20030515135144 
      20030515135202 
    12  00000000000000 *********
    其中 mysql_result_all.php 为
    <?php
    //类似于ODBC函数库的odbc_result_all函数,调试mysql应用很有用的。function mysql_result_all($result,$format="") {
      echo "<table $format><tr>";
      for($i=0;$i<mysql_num_fields($result);$i++) {
        echo "<th>".mysql_field_name($result,$i)."</th>";
      }
      echo "</tr>";
      while($row = mysql_fetch_row($result)) {
        echo "</tr>";
        for($i=0;$i<mysql_num_fields($result);$i++) {
          echo "<td>".$row[$i]."</td>";
        }
        echo "</tr>";
      }
      echo "</table>";
    }
    ?>
      

  2.   

    $sql = "SELECT Count(*) as numRows FROM table";
    $numRows = mysql_result(mysql_query($sql), 0, "numRows"); mysql_result函数的第二个参数就是行啊,默认从0开始