<div class="col-lg-3 col-md-3 col-sm-6 col-xs-6 col-xxs-12">
<div class="tm-tours-box-2">
<img src="img/index-0 <?php echo $data['id'];?>.jpg" alt="image" class="img-responsive">
<div class="tm-tours-box-2-info">
<h3 class="margin-bottom-15"><?php echo $data['name']; ?></h3>
<p>Rs <?php echo $data['price']; ?>/day</p>
</div>
<a class="tm-tours-box-2-link" onclick="POP()">Book Now</a>
</div>
</div>
<?php
}
}
?>
<?php
if(isset($_POST['submit']))
{
$username = $_POST['in'];
$Timein= date("Y-m-d H:i:s",strtotime(str_replace('/','-',$username)));
$username = $_POST['out'];
$Timeout = date("Y-m-d H:i:s",strtotime(str_replace('/','-',$username)));
$dbc = mysqli_connect('localhost','dev','dev@123','HireCamera') or die('Error while connecting Database'.mysql_connect_error);
$q="select * from camera where NOT chkin > '$Timein' AND NOT chkout < '$Timeout'";
$r = mysqli_query($dbc,$q);
while ($data = mysqli_fetch_assoc($r)) {?>
Hi,
first you should name your variables according to what they store, makes it easier to understand, or remove them if they’re not needed more than once:
$username = $_POST['in'];
$Timein= date("Y-m-d H:i:s",strtotime(str_replace('/','-',$username)));
could be changed to
// strtotime is clever enough to handle both `/` and `-` in dates
$Timein= date("Y-m-d H:i:s", $_POST['in']);
Next, logic in SQL operands is a tad confusing.
Instead of NOT < and NOT >
you can change it to
$q="select * from camera where chkin <= '$Timein' AND chkout >= '$Timeout'";
Finally, do you actually have data in your DB that matches the above conditions?
ps: you should also make sure $_POST['in']
and $_POST['out']
are not empty