Jump to content

Querying a database with Dates in PHP and MySQL with the current date


uniboy86

Recommended Posts

<?php

require "connect.php";

$today = Date('Y-m-d');

$query = "Select * from booking where arrivaldate=".$today;

$result = mysql_query($query, $connection)

or die("Unable to perform query<br>$query");

?>

<html>

<head>

<title>Date</title>

</head>

<body>

<?php  print $today ?>

<?php

while($row=mysql_fetch_array($result))

{ ?>

 

<?=$row['BookingId']?><br>

<?=$row['arrivaldate']?><br>

<?=$row['DepartureDate']?><br>

 

<? } ?>

</body>

</html>

 

I would like to know what the syntax i use to compare the current date to the ArrivalDate in a database table. I have checked the date formats and they are as follows: YYYY-MM-DD

 

Can some please help with how I do the query to check dates against current date

Link to comment
Share on other sites

  • 3 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.