我需要添加兩個下拉列表(從一個Mysql查詢)到一個表。我有一個表格顯示了r aquery的結果,然後我需要將兩列的單元格與下拉列表放在一起。這將成爲最終會創建文件的一種形式。我需要添加一個下拉列表單元
這是到目前爲止我的代碼:
<?php
$link = mysql_connect("localhost", "", "") or die ('Error connecting to mysql' . mysql_error());
mysql_select_db("cqadmin");
$sql = "SELECT id , mac FROM phones order by mac;";
$result = mysql_query($sql) or die(mysql_error());
$sql1 = "SELECT id , templatename FROM templates order by templatename;";
$result1 = mysql_query($sql1) or die(mysql_error());
$sql2 = "SELECT extension, secret from extensions;";
$result2 = mysql_query($sql2) or die(mysql_error());
echo "<table border='3'>
<tr>
<th>Extension #</th>
<th>Secret</th>
<th>MAC Address</th>
<th>Template</th>
</tr>";
while($row = mysql_fetch_array($result2))
{
echo "<tr>";
echo "<td>" . $row['extension'] . "</td>";
echo "<td>" . $row['secret'] . "</td>";
echo "<td>" . $row[''] . "</td>";
echo "<td>" . $row[''] . "</td>";
echo "</tr>";
}
echo "</table>";
?>
<p>
<select name="phone">
<?php
while($row = mysql_fetch_array($result)) {
echo '<option value="' . $row['id'] . '">' . $row['mac'] . '</option>';
}
?>
</select>
<select name="template">
<?php
while($row = mysql_fetch_array($result1)) {
echo '<option value="' . $row['id'] . '">' . $row['templatename'] . '</option>';
}
?>
</select>
</p>
<?php
mysql_close($link);
?>
我試圖選擇插入行,但頁面沒有加載,我得到一個服務器錯誤。
任何幫助深表感謝
你得到的錯誤是什麼? –
另外,如果您沒有任何迴音,請不要這樣做:echo「」。 $ row ['']。 「」;只是做回聲「」; –
爲什麼不添加