Query gebaseerd op een optie in een dropdown lijst
Ik heb dit als volgt via javascript en PHP geprogrammeerd maar bekom niet het gewenste resultaat (geen records). Wat doe ik fout ?
<script type="text/javascript">
function MM_callJS(jsStr) { //v2.0
var opd = document.form1.opdstatus.options[document.form1.opdstatus.selectedIndex].text;
alert (opd);
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?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);
}
?>
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>
Toevoeging op 12/05/2013 18:49:15:
Ondertussen reeds een betere en eenvoudigere oplossing gevonden
Er zijn nog geen reacties op dit bericht.