Jump to content

Query based on option in dropdown list


Yann63
Go to solution Solved by Yann63,

Recommended Posts

I want to see the content of a query on a webpage based on an option selected in a dropdown list (sort of filter function)

I made following javascript and PHP script but doesn't receive the desired result (no records).

What do I do wrong ?

< script type="text/javascript">
function MM_callJS(jsStr) { //v2.0
var opd = document.form1.opdstatus.options[document.form1.opdstatus.selectedIndex].text;
alert (opd);
< ?php
mysql_select_db($database_myconnection, $myconnection);
if (opd == "Started") {
$query_dashboard = "SELECT * FROM dashboard WHERE Status = 'ST' ORDER BY Deadline ASC";
$dashboard = mysql_query($query_dashboard, $myconnection) or die(mysql_error());
$row_dashboard = mysql_fetch_assoc($dashboard);
$totalRows_dashboard = mysql_num_rows($dashboard);
}
if (opd == "Finished") {
$query_dashboard = "SELECT * FROM dashboard WHERE Status = 'FN' ORDER BY Deadline ASC";
$dashboard = mysql_query($query_dashboard, $myconnection) or die(mysql_error());
$row_dashboard = mysql_fetch_assoc($dashboard);
$totalRows_dashboard = mysql_num_rows($dashboard);
}
if (opd == "Pending") {
$query_dashboard = "SELECT * FROM dashboard WHERE Status = 'PN' ORDER BY Deadline ASC";
$dashboard = mysql_query($query_dashboard, $myconnection) or die(mysql_error());
$row_dashboard = mysql_fetch_assoc($dashboard);
$totalRows_dashboard = mysql_num_rows($dashboard);
}
if (opd == "All") {
$query_dashboard = "SELECT * FROM dashboard ORDER BY Deadline ASC";
$dashboard = mysql_query($query_dashboard, $myconnection) or die(mysql_error());
$row_dashboard = mysql_fetch_assoc($dashboard);
$totalRows_dashboard = mysql_num_rows($dashboard);
}
?>
}
< /script>

 

Link to comment
Share on other sites

  • Solution

Well, there are lots of syntax errors in your script and second turn on error_reporting. 

 

Where did you find that script or you made it? 

 

I made it myself. But in the meantime I find a solution less complicated.

Thanks anywa

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.