我有這個簡單的代碼塊,它將一張表打印到屏幕上。這張表有三欄和id,汽車(下拉列表有三個選項ford,toyota和gmc)和名字。我想要做的是將特定行下拉列表選擇的值打印到屏幕上。我的方法是行不通的....PHP試圖回顯選擇下拉菜單的值到屏幕
<?php
//////connecting to our sql server
$db_connect=mysql_connect("XXXXXXXXXXXX", "XXXXXXXXX", "XXXXXXXXXXXXX")
or die("not logged in");
//////now selecting our database
$db_select=mysql_select_db("XXXXXXXXXXX") or die(mysql_error());
////query
$query = mysql_query("SELECT * FROM car ");
echo '<form action="drop_down_car_test.php?" method="GET">';
echo '<table border = \"1\">';
echo '<tr><td>id</td><td>car</td><td>name</td>';
while($row=mysql_fetch_array($query)){
echo "<tr><td>";
////in the database 'id' is the primary auto incremented id
echo $row['id'];
echo "</td><td>";
echo "<select name='carDropDown".$row['id']."' >;
<option value=\"1\">ford</option>;
<option value=\"2\">toyota</option>;
<option value=\"3\">gmc</option>;
</select>";
echo $_GET['carDropDown'.$row['id']];
echo "</td><td>";
echo $row['name'];
echo "</td><td>";
}////end while
echo"<table>";
echo '<td bgcolor=#7FFF00><input type="submit" value="Update"></td>';
echo "</form>";
?>
直到您提交表單後,它纔會打印該值。即使如此,打印的值將是「1」,「2」或「3」中的一個。另外,沒有提交按鈕。 – wanovak
即時對不起,我沒有發佈整個代碼..我現在將 – codenamejupiterx
當我提交表單它不回顯值1,2或3 – codenamejupiterx