Yann63 Posted May 12, 2013 Share Posted May 12, 2013 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.0var opd = document.form1.opdstatus.options[document.form1.opdstatus.selectedIndex].text;alert (opd);< ?phpmysql_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 https://forums.phpfreaks.com/topic/277935-query-based-on-option-in-dropdown-list/ Share on other sites More sharing options...
jazzman1 Posted May 12, 2013 Share Posted May 12, 2013 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? Link to comment https://forums.phpfreaks.com/topic/277935-query-based-on-option-in-dropdown-list/#findComment-1429763 Share on other sites More sharing options...
Yann63 Posted May 12, 2013 Author Share Posted May 12, 2013 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 https://forums.phpfreaks.com/topic/277935-query-based-on-option-in-dropdown-list/#findComment-1429765 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.