I have a drop box for Date populated from Oracle table. I need the date from drop box to be passed in a query where clause and then on the click of button records should be displayed on screen and date should be remain selected in a drop box.I have used if(isset($_POST['Date'])). This pass the date to query and data is displayed but it triggers the query when i select the date from drop box without clicking on the button which is not really required. How can i achieve this below is the code snippet:
<form action="" method="post" style="display: inline;">
<input type="submit" name="sub2" value="Rtlogs Status" />
</form>
<form action="" method="post" style="display: inline;">
<select name="Date" onchange="this.form.submit()"><option value="">Select Date</option>
<?php
$rs = ("select distinct dc_dy_bsn from RTLOGS_BO_CO_FAILED");
$sql=$db->Execute($rs);
while ($at = $sql->FetchRow()) {
echo "<option value='".$at[0]."'>".$at[1]." (".$at[0].")</option>";
}
?>
if(isset($_POST['Date'])){
$rs = $db->Execute("select * from RTLOGS_BO_CO_FAILED where dc_dy_bsn = '".$_POST['Date']."' order by 3 desc");
echo "<table class='mine'>";
$cn = 0;
while ($at = $rs->FetchRow()) {
if($cn == 0) {
echo "<tr>";
foreach ($at as $k => $v) {
if (!is_numeric($k)) {
echo "<th>" . $k . "</th>";
}
}
echo "</tr>";
}
echo "<tr>";
for ($i = 0; $i < (count($at) / 2); $i++) {
echo "<td>" . $at[$i] . "</td>";
}
echo "</tr>";
$cn++;
}
echo "</table>";
$db->Close();
}