// 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)。
我试图从查询中获取行并使用该信息进行比较。上面带有 echo 语句的代码只是为了调试目的而回显。while 循环在嵌套循环之后退出是否有特殊原因?