I have to make a booking system for a school project im really close but then this problem occured, which i cant solve.
So i hoped you guys could help me out :)
This is the PHP code getting data from the database (formulier.php):
<div id="room1" style="margin-left: 10%;"><br><br>
<img src=”source.php?id=2” width="150" height="150" />
<?php
$query = "SELECT * FROM dt_tb WHERE dt BETWEEN '2004-01-01' AND '2005-01-25'";
/* SELECT * FROM dt_tb WHERE dt BETWEEN BETWEEN '$dt1' AND '$dt2' */
$result = mysqli_query($connect,$query);
if (mysqli_num_rows($result)) {
while($row = $result->fetch_assoc()) {
echo "HERE COMES THE DESCRIPTION ";
echo " check-in: ". $row["dt"] ." | check-out: ". $row["dt2"] ." ";
}
}
else {
echo "An error occured, Please choose another date.";
}
$connect->close();
?>
<br><br><br>
<form method="post" action="#">
<input required type="submit" id="Reserve" name="Reserve" value="Book Now" style="margin-left: 0.4%;">
</form>
<hr style="width: 65%;">
</div>
<div id="room1" style="margin-left: 10%;"><br><br>
<img src=”source2.php?id=1” width="150" height="150" />
<?php
$query2 = "SELECT * FROM dt_tb WHERE dt BETWEEN '2000-01-01' AND '2100-01-25'";
/* SELECT * FROM dt_tb WHERE dt BETWEEN BETWEEN '$dt1' AND '$dt2' */
$result2 = mysqli_query($connect,$query2);
if (mysqli_num_rows($result2)) {
while($row2 = $result2->fetch_assoc()) {
echo "HERE COMES THE DESCRIPTION ";
echo " check-in: ". $row2["dt"] ." | check-out: ". $row2["dt2"] ." ";
}
}
else {
echo "An error occured, Please choose another date.";
}
$connect->close();
?>
<br><br><br>
<form method="post" action="#">
<input required type="submit" id="Reserve" name="Reserve" value="Book Now" style="margin-left: 0.4%;">
</form>
<hr style="width: 65%;">
</div>
This is the PHP code for getting the image in the database (source.php):
$query = "select * from images WHERE id = 2";
$stmt = $connect->prepare( $query );
$stmt->bindParam(2, $_GET['id']);
$stmt->execute();
$num = $stmt->rowCount();
if( $num ){
$row = $stmt->fetch(PDO::FETCH_ASSOC);
header("Content-type: image/png");
print $row['data'];
exit;
}else{
}
This is for the second image (source2.php):
$query = "select * from images WHERE id = 1";
$stmt = $connect->prepare( $query );
$stmt->bindParam(1, $_GET['id']);
$stmt->execute();
$num = $stmt->rowCount();
if( $num ){
$row = $stmt->fetch(PDO::FETCH_ASSOC);
header("Content-type: image/png");
print $row['data'];
exit;
}else{
}
These are the databases:
TABLE IMAGES
========================================
id | name | data
========================================
1 | sample image |[BLOB - 31,9 KiB]
2 | sample image2 |[BLOB - 370,8 KiB]
TABLE DT_TB
========================================
id | dt | dt2
========================================
1 | 2004-10-26 | 2005-01-25
TABLE DT_TB10
========================================
id | dt | dt2
========================================
1 | 2006-01-01 | 2007-01-25
This is the outcome: https://gyazo.com/e3263b030bd2a367e86d39db262551ba
So my problem is basically that it wont show the images from the database and that the second "booking" will show an error and not the same data as the first "booking".
I would appreciate it very much if someone could help me out with this problem.
Thanks in advance.