php如何把数据集指针移动到第一条记录? 使用mysql_data_seek
[ 2012-03-09 10:59:27 | 作者: admin ]
<?
// 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
}
?>
// 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
}
?>
http://cn.php.net/manual/zh/function.mysql-data-seek.php#66814
1