我有一个在线书店,我在那里卖书。在这里,我将购物车的数据存储在会话中。When two or more books are selected there may not be all the books available. 我只能检查一本书是否可用。But I can't make it through when two or more books selected for ordering. 我为一本书所做的是:
$result = mysql_query("SELECT id FROM book_table WHERE id IN ($cart)");
while ($row = mysql_fetch_array($result)) {
$q=mysql_num_rows(mysql_query("SELECT available FROM book_table WHERE id='$row[0]'"));
if($q!=0){
//order goes fore processing.
}
else{
//books not available.
$q2=mysql_fetch_array(mysql_query("SELECT name FROM book_table WHERE id='$row[0]'"));
echo "The book: $q2[0] Not Available";
//If there is more than 1 books in the cart and one or two books of them are not in the stock, its showing the order cant be processed(But I want to show which books aren't available).
}
}
这里 $cart 是在 1,2,3,4 这样的会话中保存的书籍购物车。现在我需要通过重定向另一个页面来显示哪些书不可购买。
谁能帮我解决这个问题?