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>";
 }
 }

解决方案 »

  1.   

    $query="select * from shangpin where ids=$xuhao";
    xuhao 序号
    显然只能查询出一条数据虽然你的代码能够处理无数条数据,但在这里就得委屈一下了
      

  2.   

    $query="select * from shangpin where ids=$xuhao";
                $result=mysql_query($query);
    你的SQL语句加的条件只允许你查询一条 !
      

  3.   

    请问要怎么改更改查询条件 , $xuhao组装成一个数组 , 然后 WHERE ids in $xuhao
      

  4.   

    请问要怎么改更改查询条件 , $xuhao组装成一个数组 , 然后 WHERE ids in $xuhao我觉得你这么说他待会还要问,封装成一个数组之后这么写$xuhao = implode(',',$xuhao),WHERE ids in "($xuhao)"