good day guys;
I hope somebody could help me again with my problem
I'm working with this for a month now and It seems I cant analyze what's wrong with my code.
now here's what I want to happen
I want to count and pull the records from a table called `medicalrecords` where the date is (exclusive) from $fromDate to $toDate.
here's my code:
<!------- DOWnloaded Date Picker --------------------->
<form action="" method="POST" name="datepick">
<label for="datefrom">From:</label>
<input type="Text" id="datefrom" name="datefrom" value="<?php echo $_GET['datefrom']; ?>" maxlength="25" size="25"/>
<img src="images/cal.gif" onclick="javascript:NewCssCal('datefrom')" style="cursor:pointer"/>
<label for="dateTo">To:</label>
<input type="Text" id="dateto" name="dateto" value="<?php echo $_GET['dateto']; ?>" maxlength="25" size="25"/>
<img src="images/cal.gif" onclick="javascript:NewCssCal('dateto')" style="cursor:pointer"/>
<input type="submit" value="Go" />
</form>
</div>
<br />
<div id="countdept">
<!-------------------------------- the query ------------------------------->
<?php if (isset($_POST['datefrom']) && isset($_POST['dateto'])) {
$datefrom = $_POST['datefrom'];
$dateto = $_POST['dateto'];
$fromDate = strtotime('Y-m-d', $datefrom);
$toDate = strtotime('Y-m-d', $dateto);
if (!empty($datefrom) && !empty($dateto)) {
$queryOne = "SELECT diagnosisName, COUNT(1) as numberOfRecords FROM medicalrecords
Inner Join diagnosis ON medicalrecords.diagnosisId = diagnosis.diagnosisId
WHERE DATE BETWEEN '$fromDate' AND '$toDate'
GROUP BY diagnosisName";
$queryOne_run = mysql_query($queryOne);
$queryOne_num_rows = mysql_num_rows($queryOne_run);
$rsReport = mysql_fetch_assoc($queryOne_run);
?>
<!------------ table --------------------->
<table border="2" cellpadding="2" cellspacing="2" align="center">
<tr bgcolor="#00ccff">
<th>Sickness</th>
<th>Number Of Patient</th>
</tr>
<?php do { ?>
<tr>
<td><?php echo $rsReport['diagnosisName']; ?></td>
<td><?php echo $rsReport['numberOfRecords']; ?></td>
</tr>
<?php } while ($queryOne_num_rows = mysql_fetch_assoc($queryOne_run));
}
}
?>
</table>
if you have a more suitable form for this, please share it to me.. it would be a greet help. I'm bloody stuck with this problem.