I'm new here and I learn PHP and SQL connection. I want to list from the SQL database the room numbers what are not reserved. I create 2 tables ( rooms and reservation ) with fill some exapmles.
Step 1
If I put direct DATE for the "end reservation" DATE("2019-03-11") like this work well and listed the room numbers
function reserv3()
{
include "config.php";
$html = "";
$sql = 'SELECT roomnr , reserv_start FROM rooms LEFT OUTER JOIN reservation ON reservation.room_id = rooms.room_id AND DATE(reservation.reserv_start) >= DATE("2019-03-11")';
$result = mysqli_query($conn, $sql);
while( $sor = mysqli_fetch_array($result) )
$html .= "<DIV>".$sor['roomnr'].", ".$sor['reserv_start']."</DIV>";
return $html;
}
Step 2
I want to replace the fixed DATE("2019-03-11") to a variable.
$today = DATE("2019-03-11");
function reserv3($today)
{
include "config.php";
$html = "";
$sql = 'SELECT roomnr , reserv_start FROM rooms LEFT OUTER JOIN reservation ON reservation.room_id = rooms.room_id AND DATE(reservation.reserv_start) >= '.$today;
$result = mysqli_query($conn, $sql);
while( $sor = mysqli_fetch_array($result) )
$html .= "<DIV>".$sor['roomnr'].", ".$sor['reserv_start']."</DIV>";
return $html;
}
I have in Step 2 the Fatal error Fatal error: Uncaught ArgumentCountError: Too few arguments to function reserv3(), 0 passed in
Can you help me how can I put variable to this command ? Thank you