从包含大量$values
语句的$key
循环中的foreach
(包含' s')或if
获取多个未定义的索引。不确定在我的代码中使用isset
的位置。是因为多维数组吗?
if($num_row)
{
$html = "<table id=\"myTable\" border=\"1\">";
$html .= "
<tr>
<th></th>
<th></th>
<th>matching(%)</th>
<th>HSD-M</th>
<th>Turbo-Frame</th>
<th>SupportBoard</th>
<th>DistributionBoard</th>
<th>DC-30</th>
<th>GigaDigHD2</th>
<th>HSS-6400</th>
<th>HexVS</th>
</tr>
<tr><td>Device</td>
<td>$device_name</td>";
while($row = mysql_fetch_assoc($result))
{
$tester_name = $row['tester_name'];
$config = $row['config'];
$req_config = $row['configuration'];
$board_name = $row['board_name'];
//multi array used here
$table_row{$tester_name}{$board_name} .= $config.",";
} //while
//var_dump($table_row);
foreach ($table_row as $i => $values)
{
//echo $i." ";
$html .= "<tr><td>Tester</td>";
$html .= "<td>$i</td>";
$hsd = "None";
$turbo = "None";
$supp = "None";
$distrib = "None";
$dc = "None";
$giga = "None";
$hss = "None";
$hex = "None";
foreach ($values as $key => $value)
{
//echo $value;
if($key == "DC-30")
{
$dc = $value;
}
elseif($key == "GigaDigHD2")
{
$giga = $value;
}
elseif($key == "HSD-M")
{
$hsd = $value;
}
elseif($key == "HSS-6400")
{
$hss = $value;
}
elseif($key == "HexVS")
{
$hex = $value;
}
elseif($key == "Turbo-Frame")
{
$turbo = $value;
}
elseif($key == "SupportBoard")
{
$supp = $value;
}
elseif($key == "DistributionBoard")
{
$distrib = $value;
}
//echo "$key<br>";
}
$html .= "<td>%</td>
<td>$hsd</td>
<td>$turbo</td>
<td>$supp</td>
<td>$distrib</td>
<td>$dc</td>
<td>$giga</td>
<td>$hss</td>
<td>$hex</td>
</tr>";
}
$html .= "</table>";
echo $html;
}
编辑:我知道错误意味着什么。但是我不确定在我的代码中要改变什么。我知道它的要点是使用isset
设置它是否尚未设置。我不确定是否应该为if循环中的每个变量设置我不这么认为,因为通知/错误指向索引,我不知道如何更改它因为我&# 39; m使用多维数组。