// current session id
$sid = session_id();
// get current cart session
$sql = "SELECT * FROM tbl_cart WHERE ct_session_id = '$sid'";
$result = dbQuery($sql);
// get all the items in the car category
$query = "SELECT pd_id FROM tbl_product WHERE cat_id ='28'";
$r = dbQuery($query);
//Cycle through the cart and compare each cart item to the cars to determine
if the cart contains a car in it.
while($cart = dbFetchAssoc($result)){
while($product = dbFetchAssoc($r)){
echo $cart['pd_id'] . " - ";
echo $product['pd_id']. "<br>";
}
}
dbFetchAssoc()是一個基本上是(mysql_fetch_assoc)的自定義數據庫層。爲什麼我的容器while循環僅循環第一個項目?
我試圖從查詢中獲取行並使用該信息進行比較。使用echo語句的上面的代碼只是迴應調試目的。是否有一個特定的原因,循環嵌套後退出while循環?
what sizeof(dbFetchAssoc($ r))說? –