-1
我使用嵌套while循环创建一个嵌套的数组,这将是这样的:嵌套阵列,同时在循环
[276] => Array
(
[0] => 302
)
[279] => Array
(
[0] => 290
[1] => 291
[1] => 223
但由于某些原因,我只得到一个嵌套的数组显示上涨了279下,但我知道,我要查询的 数据至少返回了应该在279阵列下的12条记录。
这里是我的,而循环代码:
while ($row = mysql_fetch_assoc($result)) {
$term_id = $row[term_id];
// Look up Children Categories
$sql2 = "SELECT * FROM wp_term_taxonomy wpt where parent = $row[term_id]";
// execute query:
$result2 = mysql_query($sql2) or die('A error occured: ' . mysql_error());
// fetch results:
$count_2 = "0";
while ($row2 = mysql_fetch_assoc($result2)) {
$term_id2 = $row2['term_id'];
$arr[$term_id] = array($count_2 => $row2[term_id]);
$count_2++;
}
}
有人能告诉我什么林做错了什么?它就像每次重置嵌套数组,所以我只在嵌套数组下面得到一条记录。
伙计,你应该被禁止。 http://stackoverflow.com/questions/3552456/smarty-nested-foreach-loop-question – Phil