2013-01-24 2 views
0
<?php 
ini_set("display_errors","on"); 
$conn = new COM("ADODB.Connection"); 
    try { 
    $myServer = "WTCPHFILESRV\WTCPHINV"; 
    $myUser = "sa"; 
    $myPass = "[email protected]"; 
    $myDB = "wtcphitinventory"; 
    $connStr = "...conn string..."; 
    $conn->open($connStr); 
     if (! $conn) { 
      throw new Exception("Could not connect!"); 
     } 
    } 
    catch (Exception $e) { 
     echo "Error (File:): ".$e->getMessage()."<br>"; 
    } 
if (!$conn) 
    {exit("Connection Failed: " . $conn);} 
    $sql_exp = "select * from dbo.PC"; 
    $rs = $conn->Execute($sql_exp); 
echo "<table><tr><th>Desktop Number</th></th></tr>"; 
    while (!$rs->EOF) { 
     set_time_limit(0);  
     echo "<td>CP # <br>".$rs->Fields("PC_Number")."</td>";   
     $rs->MoveNext(); 
    } 
    echo "</table>"; 
    $rs->Close(); 
     ?> 

데이터베이스에서 PC_Number의 모든 데이터를 인쇄하는 대신 목록 상자를 갖고 싶습니다. 내가 할 수있는 일은 그것을 반향시키고 선택을 삽입하는 데 어려움을 겪는 것 뿐이다. 내가 선택한 양식 목록 게시물을 가지고 싶습니다 (목록 상자)데이터베이스의 데이터로 목록 상자 채우기

답변

1

while 문에서 목록 상자를 만듭니다.

echo "<table border='1' cellpadding='1' cellspacing='0' id='rounded-corner'><tr><th>Desktop Number</th></th></tr>"; 


    echo "<tr><td><select name='selectionField'>"; 
    while (!$rs->EOF) { 
     set_time_limit(0); 
     echo "<option value=".$rs->Fields('PC_Number')." >".$rs->Fields('PC_Number')."</option>"; 
     $rs->MoveNext(); 
    } 
    echo "</td></tr></table>"; 
+0

THAAAAAAAAAAAAAAAAAAAAAAAAANANK YOU! – Yinks

관련 문제