我正在尝试使用两个不同的查询在PHP中构建一个2d数组。 由于某种原因,页面未显示有关发生的任何错误的任何消息。 它就像数组不存在一样反应。
因此我假设它,因为我没有正确处理数组。
这是代码:
$stuarr= array(); ***//the 2d array initialization***
$query1 = "SELECT * FROM students WHERE userid= '$uid' ORDER BY name";
$stulist = mysqli_query($conn,$query1) or die ("cannot query the table1 " .mysqli_error($conn));
while ($students = mysqli_fetch_array($stulist)) {
${$students['name']}= array(); ******//the inside array initialization...the one that will insert to $stuarr***
$count=$_SESSION['counter'];
$sname=$students['name'];
$query3 = "SELECT * FROM ranks WHERE userid= '$uid' AND rankers='$sname' ORDER BY therate DESC";
$stur = mysqli_query($conn,$query3) or die ("cannot query the table1 " .mysqli_error($conn));
while ($sturank = mysqli_fetch_array($stur) && !$count==0) {
array_push(${$students['name']},$sturank['rated']);
$count=$count-1;
print_r(${$students['name']});
}
array_push($stuarr,${$stulist['name']});
print_r($stuarr); ***///this print is showing nothing***
}
我很想听听您对代码的看法。
谢谢你!答案 0 :(得分:0)
更改
df.query("Class == 'Class1' | Class == 'Class2'")
#here working or too
#df = df.query("Class == 'Class1' or Class == 'Class2'")
到
array_push($stuarr,${$stulist['name']});