// 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ループがネストされたループの後に終了する特別な理由はありますか?