复制代码 代码如下:
<?
// Start snipit 1
$sql = "SELECT * from <table>";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)) {
// do stuff with $row
}
mysql_data_seek($result, 0); //关键是这儿
while ($row = mysql_fetch_assoc($result)) {
// do other stuff with $row
}
?>
复制代码 代码如下:
<?php
$con = mysql_connect("localhost", "hello", "321");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db("test_db",$con);
$sql = "SELECT * from Person";
$result = mysql_query($sql,$con);
print_r(mysql_fetch_row($result));
mysql_data_seek($result,3);
print_r(mysql_fetch_row($result));
mysql_close($con);
?>
复制代码 代码如下:
Array
(
[0] => Adams
[1] => John
[2] => London
)
Array
(
[0] => Carter
[1] => Thomas
[2] => Beijing
)
新闻热点
疑难解答