-1

I want to search employee list depend on area name which is selected from dropdown list. I can retrieve names of areas from database into dropdown list from PHP HTML. But now I am confused how to pass selected option in dropdown list to SQL query in PHP. Also I want index numbers of selected options. My code is as follows.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
include 'Connect.php';
$query = "SELECT varAreaName FROM tbArea" ;
$result = mysql_query($query);
echo'<select name="somename">';
echo'<option value="ANY">--ANY--</option>';
while($row = mysql_fetch_assoc( $result )) { 
    echo '<option value="'.$row['varAreaName'].'">' . $row['varAreaName'] . '</option>';   
}
echo '</select>';                
?>
</body>
</html>

Also I want the output on same form using Javascript. But I am new in JavaScript. Please help me to sort this out.

4

1 回答 1

1

为此,您可能想了解 AJAX。仅当有另一个脚本执行服务器端操作(在本例中为数据库查询)时,才可能使用 javascript 从数据库中动态更改页面。

这应该让你朝着这个方向前进。http://api.jquery.com/jQuery.ajax/

此外,强制 - 请不要使用 MySQL,因为它已被弃用并且不再由 PHP 维护。使用 MySQLi 或 PDO。

于 2013-02-18T14:05:16.163 回答