i am getting no error and no values for $con2 and $con3 when AND icutype = $icutype added in where clause.When removed i am getting total output correctly.
<?Php
$con = mysqli_connect("localhost","root","","nimicudb");
$con2 = mysqli_connect("localhost","root","","nimicudb");
$con3 = mysqli_connect("localhost","root","","nimicudb");
if (mysqli_connect_errno()){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
die();
}
if(!empty($_POST) && $_SERVER['REQUEST_METHOD'] == 'POST'){
$icutype = $_POST["icutype"];
$fromdate = $_POST['fromdate'];
$todate = $_POST['todate'];
$sql1= mysqli_query($con,"SELECT COUNT(name) FROM `patients` WHERE date BETWEEN '$fromdate' AND '$todate' AND icutype = '$icutype'");
$row = mysqli_fetch_array($sql1);
$totalpatients=$row[0];
$sql2= mysqli_query($con,"SELECT icubedstrength FROM `icustrength` WHERE icuname = '$icutype' ");
$row1 = mysqli_fetch_array($sql2);
$totalbeds=$row1[0];
$sql3= mysqli_query($con2,"SELECT COUNT(icureturn48) FROM `patients1` WHERE date BETWEEN '$fromdate' AND '$todate' AND icutype = '$icutype' ");
$row2 = mysqli_fetch_array($sql3);
$totalicureturn48=$row2[0];
$sql4= mysqli_query($con,"SELECT COUNT(datedischarge) FROM `patients` WHERE date BETWEEN '$fromdate' AND '$todate' AND icutype = '$icutype'");
$row3 = mysqli_fetch_array($sql4);
$totaldischarge=$row3[0];
$sql5= mysqli_query($con3,"SELECT COUNT(reintbn48) FROM `patients2` WHERE date BETWEEN '$fromdate' AND '$todate' AND icutype = '$icutype'");
$row4 = mysqli_fetch_array($sql5);
$totalreintubation=$row4[0];
$sql6= mysqli_query($con,"SELECT COUNT(tubedate) FROM `patients` WHERE date BETWEEN '$fromdate' AND '$todate' AND icutype = '$icutype'");
$row5 = mysqli_fetch_array($sql6);
$totalintubation=$row5[0];
$totaldays = (strtotime($todate) - strtotime($fromdate)) / (60 * 60 * 24);
echo "TOTAL DAYS - $totaldays </br>";
echo "TOTAL PATIENTS - $totalpatients</br>";
echo "TOTAL BEDS - $totalbeds</br>";
echo "TOTAL discharge - $totaldischarge</br>";
echo "TOTAL intubation - $totalintubation</br>";
echo "TOTAL PATIENTS returned - $totalicureturn48</br>";
echo "TOTAL reintubation - $totalreintubation</br>";
$icureturnrate=(round(($totalicureturn48/$totaldischarge)*100));
$reintubation_rate=(round(($totalreintubation/$totalintubation)*100));
$urate=(round(($totalpatients/$totalbeds)*$totaldays));
echo "utilization rate is : $urate</br>";
echo "% Return to ICU within 48 hours is : $icureturnrate </br>";
echo "% Re-intubation rate is : $reintubation_rate";
}
?>
<html>
<form action='search.php' method='POST'>
<h5>SELECT ICU</h5>
<select name='icutype' >
<option value="EICU">EICU</option>
<option value="NMICU">NMICU</option>
<option value="NSICU">NSICU</option>
<option value="SBICU">SBICU</option>
</select>
</br>
FROM DATE<input type="date" name="fromdate" value="<?php echo date('Y-m-d', strtotime('-30 days')); ?>"></br>
TO DATE<input type="date" name="todate" value="<?php echo date('Y-m-d'); ?>"></br>
<input type='submit' name='calsubmit' value="CALCULATE"/>
</form>
</html>
This is my page where i need advice.
THE OUTPUT OF THIS DISPLAYED LIKE BELOW
TOTAL DAYS - 30
TOTAL PATIENTS - 1
TOTAL BEDS - 6
TOTAL discharge - 1
TOTAL intubation - 1
**TOTAL PATIENTS returned - 0
**TOTAL reintubation - 0
utilization rate is : 5
% Return to ICU within 48 hours is : 0
% Re-intubation rate is : 0
THE **
MARKED ITEMS ARE NOT GIVING ANY OUTPUT WHEN THE AND ADDED TO WHERE CLAUSE ( AND icutype = '$icutype'
)
Hai guys i sorted it out. The problem is with some whitespace got saved along with the data in icutype column.I changed icutype =$icutype to icutype LIKE '%$icutype%' and it worked like helll. Thanks guys.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.