$result = mysql_query("SELECT *SOMETHING* ");
$i = 1;
$allRows = mysql_num_rows($result);
while($row = mysql_fetch_array($result)){
if ($allRows == $i) {
/* Do Something Here*/
} else {
/* Do Another Thing Here*/}
}
$i++;
}
但请考虑 PDO
$db = new PDO('mysql:host=localhost;dbname=testdb', 'username', 'password');
$stmt = $db->query("SELECT * FROM table");
$allRows = $stmt->rowCount();
$i = 1;
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
if ($allRows == $i) {
/* Do Something Here*/
} else {
/* Do Another Thing Here*/}
}
$i++;
}