I have created a function (works fine) that will display a dropdown list of a columns values in a table. I want to create a dynamic sql WHERE clause based on the fields on a form and the values in them. When I place this statement in an empty script the text box works fine:
getdata("e107_act_emps", "position", "title", "title");
When I try and put it on a form nothing happens. The form will have the many fields found in an employee table that my users want to query on.
Can someone show me the code for a form that will have 2 drop down boxes using the function below.
<script>
<?
function getdata($file, $key, $desc, $order){
$sql = mysql_query("SELECT distinct $desc, $key FROM $file order by $order");
echo "<select name=$desc>";
while(list($desc, $key)=mysql_fetch_array($sql)){
$desc = stripslashes($desc);
echo "<option value=$key>$desc</option>";
}
echo "</select>";
mysql_free_result($sql);
}
?>
</script>
getdata("e107_act_emps", "position", "title", "title");
When I try and put it on a form nothing happens. The form will have the many fields found in an employee table that my users want to query on.
Can someone show me the code for a form that will have 2 drop down boxes using the function below.
<script>
<?
function getdata($file, $key, $desc, $order){
$sql = mysql_query("SELECT distinct $desc, $key FROM $file order by $order");
echo "<select name=$desc>";
while(list($desc, $key)=mysql_fetch_array($sql)){
$desc = stripslashes($desc);
echo "<option value=$key>$desc</option>";
}
echo "</select>";
mysql_free_result($sql);
}
?>
</script>