foreach($aaa as $n)
{
$xuhao=$n[0];
$query="select * from shangpin where ids=$xuhao";
$result=mysql_query($query);
if(!$result)
{
die("could not to the database<br/>".mysql_error());
}
//-------------------封装函数-----------------------------
//该函数将数据库的数据写成数组形式
function result2Arr($result){
while($result_row=mysql_fetch_assoc($result)){
$arr[] = $result_row;
}
return $arr;
}
//arr = result2Arr($result);
$arr = result2Arr($result);
foreach($arr as $v)
{
echo "<table width='1350' border='1px' style='TABLE-LAYOUT: fixed'>";
echo "<tr> ";
echo "<td width='150px'>".$v['names']."</td>";
echo "<td width='150px'>".$v['jiage']."</td>";
echo "<td width='150px'>".$n[1]."</td>";
echo "<td width='300px'><a href='add5.php?ids=$v[ids]'>删除</a></td>";
echo "</tr>";
echo "</table>";
}
}
{
$xuhao=$n[0];
$query="select * from shangpin where ids=$xuhao";
$result=mysql_query($query);
if(!$result)
{
die("could not to the database<br/>".mysql_error());
}
//-------------------封装函数-----------------------------
//该函数将数据库的数据写成数组形式
function result2Arr($result){
while($result_row=mysql_fetch_assoc($result)){
$arr[] = $result_row;
}
return $arr;
}
//arr = result2Arr($result);
$arr = result2Arr($result);
foreach($arr as $v)
{
echo "<table width='1350' border='1px' style='TABLE-LAYOUT: fixed'>";
echo "<tr> ";
echo "<td width='150px'>".$v['names']."</td>";
echo "<td width='150px'>".$v['jiage']."</td>";
echo "<td width='150px'>".$n[1]."</td>";
echo "<td width='300px'><a href='add5.php?ids=$v[ids]'>删除</a></td>";
echo "</tr>";
echo "</table>";
}
}
xuhao 序号
显然只能查询出一条数据虽然你的代码能够处理无数条数据,但在这里就得委屈一下了
$result=mysql_query($query);
你的SQL语句加的条件只允许你查询一条 !