考虑这个(简化的)代码...调用函数getLevelOne,运行正常,调用getLevelTwo,运行正常,然后停止,而不继续在getLevelOne中调用的while ...它的编写方式,你是假设将为$ list1(2,4,5,6)中的每个数字调用第二个函数...我错过了什么?
$list1 = "2,4,5,6";
$table1 = 'thistable';
getLevelOne($list1, $table1);
function getLevelOne($list1, $table1){
$q = "select * from $table1 where id IN ('$list1')";
$r = mysqli_query($db, $q);
while($row = mysqli_fetch_array($r)){
echo 'oh';
$table2 = 'nexttable';
$list2 = $row[$table2];
getLevelTwo($list2, $table2);
}
}
function getLevelTwo($list2, $table2){
$q2 = "select * from $table2 where id IN ('$list2')";
$r2 = mysqli_query($db, $q2);
while($row2 = mysqli_fetch_array($r2)){
echo 'shit';
}
}