I cant get the data from my db which I need to display it.
<label style="font-size:20px"><b>Doctor:</b></label><br>
<select name="doctor" id="doctor-list" class="demoInputBox" style="width:100%;height:35px;border-radius:9px">
<option value="">Select Doctor</option>
<?php
session_start();
$mid=$_SESSION['mgrid'];
$sql1="SELECT * FROM doctor where did in(select did from doctor_availability where cid in (select cid from manager_clinic where mid=$mid));";
$results=$conn->query($sql1);
while($rs=$results->fetch_assoc()) {
?>
<option value="<?php echo $rs["did"]; ?>"><?php echo "Dr. ".$rs["name"]; ?></option>
<?php
}
?>
</select>
<br>
<label><b>Date:</b></label><br>
<input type="date" name="dateselected" required><br><br>
<br>
<button type="submit" style="position:center" name="submit" value="Submit">Submit</button>
</form>
<?php
if(isset($_POST['submit']))
{
include 'dbconfig.php';
$did=$_POST['doctor'];
$cid=1;
$dateselected=$_POST['dateselected'];
$sql1 = "SELECT * FROM book WHERE DOV='". $_POST['dateselected']."' AND DID= $did AND CID= $cid order by Timestamp ASC";
$results1=$conn->query($sql1);
require_once("dbconfig.php");
?>
I have a table book
there is lot of values there. If I choose the date it must be display all of the same values where dates are the same.
$cid=1;
[book table1
I am not entirely sure, but I think you need JOINs and definitely you need prepared statements. See my code below. I used JOINs to connect the 3 tables together and then I used your session value to match the mid
.
session_start();
if (isset($_POST['submit'])) {
include 'dbconfig.php';
$stmt = $conn->prepare('SELECT * FROM book
JOIN doctor_availability USING(did)
JOIN manager_clinic USING(cid)
WHERE dov=? AND did=? AND mid=?');
$stmt->bind_param('sii', $_POST['dateselected'], $_POST['doctor'], $_SESSION['mgrid']);
$stmt->execute();
$results1 = $stmt->get_result();
}