如何将mssql中的数据放入列表框? PHP

时间:2013-01-21 06:22:58

标签: php html sql-server-2008

if (!$conn)
  {exit("Connection Failed: " . $conn);}

   $sql_exp = "select * from dbo.PC inner join dbo.FA_PC on dbo.PC.PCID = dbo.FA_PC.PCID WHERE UserID is NOT NULL order by dbo.fa_pc.PCID"; 
   $sql_exp1= "select * from dbo.users inner join dbo.FA_PC on dbo.users.UserID = dbo.FA_PC.UserID order by dbo.fa_pc.PCID";
   $sql_exp2 = "SELECT * FROM dbo.FA_PC WHERE FA_TypeID is NOT NULL ORDER BY PCID"; 
   $rs = $conn->Execute($sql_exp);
    $rs1 = $conn->Execute($sql_exp1);
   $rs2 = $conn->Execute($sql_exp2);
   echo "<table border='1' cellpadding='1' cellspacing='0' id='rounded-corner'><tr><th>Desktop Number</th><th>Employee</th><th><p align=left>Fixed Asset Accountability</p></th></tr>";
   while (!$rs->EOF) {
       set_time_limit(0);
       echo "<td>CP # <br>".$rs->Fields("PC_Number")."</td>";   
       echo "<td>".$rs1->Fields("EmployeeName")."</td>";    
       echo "<td>".$rs2->Fields("FA_TypeID")."</td><tr>";   

      $rs->MoveNext();
      $rs1->MoveNext();
   }
   echo "</table>";   
   $rs->Close();
       ?>   

我怎么能将$ rs-&gt;字段(“PC_Number”)放入一个列表框中,该列表框将以新的形式提交

1 个答案:

答案 0 :(得分:0)

如果$rs->Fields("PC_Number")不是数组,你可以使用它。如果它是一个数组,你必须使用循环语句...这将给你一个只包含一个选项的列表框..

<select>
   <option value="1"><?php echo $rs->Fields("PC_Number");?></option>
</select>