我需要使下拉列表作爲鏈接到不同的頁面。我該如何使用PHP,MySQL和HTML來做到這一點。下拉列表中的PHP和MySQL
<?php
mysql_connect('localhost','root','');
mysql_select_db('test');
$sql="select first_name from users";
$result=mysql_query($sql);
echo "<select First_name=''>";
echo "<a href='index.html'>";
while($row=mysql_fetch_array($result)){
echo ":<option value='".$row['first_name']."'>".$row['first_name']."</option>";
}
echo"</a>";
echo"</select>";
?>
如果你正在編寫新的代碼,** _ please_不使用'mysql_ *'功能**。它們已經老化並且破損,在PHP 5.5中已經被棄用了(這已經很舊了,它甚至不再接收安全更新),並且在PHP 7中完全刪除。使用['PDO'](https://secure.php.net/manual /en/book.pdo.php)或['mysqli_ *'](https://secure.php.net/manual/en/book.mysqli.php)替換爲_prepared statements_和_parameter binding_。有關詳細信息,請參閱http://stackoverflow.com/q/12859942/354577。 – Chris
當點擊下拉列表中的某個名稱時,我需要獲取屬於該名稱的詳細信息。我該怎麼做。 –
我建議你用新的細節更新你的文章。 –