I have a PHP page: page.php
At some point in the file there is a javascript function.
Code:
function popAirType(){
var db = document.forms[0].db.value;
AddToOptionList(document.forms[0].air_type, "","Select Airplane Type");
<?php $query_string = "SELECT distinct air_type FROM my_table";
$air_types = mysql_query($query_string);
while ($air_types_row = mysql_fetch_array($air_types)){
echo "AddToOptionList(document.forms[0].air_type, '" . $air_types_row['air_type'] ."', '" . $air_types_row['air_type'] . "');";
}
?>
}
Now, this code works great. i loop through the results of the query and (in php) echo out the appropriate javascript code to create the options in an html select box. No problems here.
What i'd like to do is add a WHERE clause to the query.
WHERE db_version = '(in here i want the javascript variable db)'
As you can see, I declare the variable "var db" at the first line of the function.
Is there anyway I can put the javascript variable inside the query I am running??