sql for loop php只给出了数组

时间:2017-07-28 16:52:48

标签: php mysql arrays

所以我从表格中获取了数据,并且我试图配对主要文件夹'使用' parent_id'但是当我显示结果时,最终数组只包含数据库中的最后三个结果。我非常困惑。

我已经使用一系列'主文件夹'与' id'配对for parent_id = 0.它绝对正常。我很生气。

//This for loop works absolutely fine
while($parents[] = mysqli_fetch_array($result)) {
    //Adding values from sql table row by row into parents[]
}

for($i = 0; $i < (count($parents) - 1); $i++) {
    $ParentsArray[$parents[$i]['mainfolder']] = $parents[$i]['id'];
}

//Problem starts with this for loop below

while($children[] = mysqli_fetch_array($subResult)) {
    //Adding values from sql table row by row into children[]
}
var_export($children);

for($b = 0; $b < (count($children) - 1); $b++) {
    echo $b;
    $ChildrenArray[$children[$b]['mainfolder']] = $children[$b]['id'];
}
var_export($ChildrenArray);

0 个答案:

没有答案