我的代码如下所示
$number_of_book=0;
$res_best_book=mysql_query("SELECT * FROM book ORDER BY best DESC");
while($best_book=mysql_fetch_assoc($res_best_book)){
echo "Number Of Book";$number_of_book++;
echo "&nbsb;&nbsb;";
print_r($best_book['book_name']);
echo "<br>";
}
这是我的实际输出:
Number Of Book BOOK58
Number Of Book BOOK91
Number Of Book BOOK532
Number Of Book BOOK1
Number Of Book BOOK21
Number Of Book BOOK84
预期输出
Number Of Book 1 BOOK58
Number Of Book 2 BOOK91
Number Of Book 3 BOOK32
Number Of Book 4 BOOK1
Number Of Book 5 BOOK21
Number Of Book 6 BOOK84
答案 0 :(得分:0)
试试这个:
$number_of_book=1;
$res_best_book=mysql_query("SELECT * FROM book ORDER BY best DESC");
while($best_book=mysql_fetch_assoc($res_best_book)){
echo "Number Of Book ".$number_of_book++." ".$best_book['book_name']." <br>";
$number_of_book++;
}
答案 1 :(得分:0)
$number_of_book=1;
$res_best_book=mysql_query("SELECT * FROM book ORDER BY best DESC");
while($best_book=mysql_fetch_assoc($res_best_book)){
echo "Number Of Book".$number_of_book;
echo "&nbsb;&nbsb;";
print_r($best_book['book_name']);
echo "<br>";
$number_of_book++;
}