我解决不了这个。
我有多个while,而里面的那个只获取第一个结果并停止......
这是代码:
$categories 是一个数组
array(18) {
[0] => array(7) {
["category_id"] => string(1) "1"
["category_name"] => string(5) "pizza"
["category_display"] => string(5) "pizza"
["category_active"] => string(1) "1"
["category_parent"] => string(1) "0"
["category_position"] => string(1) "1"
["category_user_discount"] => string(2) "50"
}
[1] => array(7) {
["category_id"] => string(1) "2"
["category_name"] => string(4) "menu"
["category_display"] => string(4) "menu"
["category_active"] => string(1) "1"
["category_parent"] => string(1) "0"
["category_position"] => string(1) "2"
["category_user_discount"] => string(2) "30"
}
}
$stmt = $db->query("SELECT sell_id FROM sell WHERE sell.sell_status = 'close' AND sell_period_id >= '".$liste[0]."' AND sell_period_id <= '".$liste[1]."' ");
foreach ($categories as $cat)
{
while ($sell2 = $stmt->fetch())
{
$stmt2 = $this->db->query("SELECT * FROM sellcart WHERE sellcart_status = 'close' AND sellcart_sell_id = '".$sell2['sell_id']."' ");
while ($sellitem = $stmt2->fetch())
{
echo $sellitem['sellcart_item_category'];
}
}
}
第一个循环没问题,但它不会循环到第二个 $cat ...
任何想法 ?
谢谢你的帮助 !!!