我有一个查询,可以在我的外借表中找到前 10 本书,但是我想将这十个值存储到一个数组中,以便我可以再次使用该数组。这是我到目前为止的代码......提前感谢您的帮助!
//select a database to work with
$selected = mysql_select_db("ds2",$dbhandle)
or die("Could not select examples");
//execute the SQL query and return records
$result = mysql_query("SELECT book.title, book.book_id, count(book.book_id) AS count_book_id, loan.book_id FROM book
INNER JOIN loan ON book.book_id = loan.book_id
GROUP BY book.book_id ASC
ORDER BY count(book.book_id) DESC");
$titles = array();
while($row = mysql_fetch_array($result))
{
echo $row['title'];
echo "<br>";
}
echo "<br><br>";
for($index = 1; $index <= 10; $index++)
{
array_push($titles,$result[$row]);
print_r($titles);
echo "<br>";
}