所有这一切的最终结果应该是应该填充用于描述和传递的数组,并且我应该能够回应它们。但是,只有描述会回显,而密码不会回显。从我的所有测试来看,对于 result1 查询,$value 变量似乎是空的。我不知道如何在第二个查询中使用 $value。
我也收到这两个错误:注意:未定义的变量:在第 60 行传入 /var/www/html/manage/commit.php 警告:在 /var/www/html/manage/commit 中为 foreach() 提供的参数无效。第 60 行的 php
// From manage.phones
$result = mysqli_query($con_manage,"SELECT * FROM phones");
while($row = mysqli_fetch_array($result))
{
$mac[] = $row['mac'];
$mapped_to[] = $row['mapped_to'];
}
// From asterisk.devices
foreach($mapped_to as $value)
{
$result = mysqli_query($con_asterisk,"SELECT description as description FROM devices WHERE id='$value'");
while($row = mysqli_fetch_array($result))
{
$description[] = $row['description'];
}
$result1 = mysqli_query($con_asterisk,"SELECT data as data FROM sip WHERE id='$value'");
while($row = mysqli_fetch_array($result))
{
$pass[] = $row['data'];
}
}
// Echo the descriptions and passwds!
echo "Echo all descriptions:";
echo"\n";
foreach($description as $key => $value)
{
echo "$value\n";
}
echo "Echo all passwds:";
echo"\n";
foreach($pass as $key => $value)
{
echo "$value\n";
}