a.html
function load(str)
{
xhttp.open("GET","a.php?q="+str,true);
xhttp.send();
}
}
<select name = "select" onchange ="load(this.value)">
<option selected = "selected">Select a movie</option>
<option value= "asc">Name in ascending order</option>
<option value = "genre">Genre</option>
</select>
a.php只会
$asc = $_POST['asc'];
$genre = $_POST['genre'];
if (!empty($_GET[$asc])) {
$sql = "SELECT * FROM movies order by Name ASC";
} else if (!empty($_GET[$genre])) {
$sql = "SELECT * FROM movies order by Genre ASC";
}
$db = mysql_connect("localhost","root","123");
$db_select = mysql_select_db('m',$db);
if ( ( $result = mysql_query( $sql, $db ) ) ) {
echo $result;
}
我想从下拉按钮中选择值。例如asc
,并将值传递给a.php ($asc = $_POST['asc'])
。我怎么能这样做?