Loading ...
Sorry, an error occurred while loading the content.
 

Re: [phpXperts] Need help with Date comparison

Expand Messages
  • alcarterguitars
    Thank you very much. ... startdate= $startdate AND (CURDATE() + INTERVAL 3 DAY)
    Message 1 of 3 , Sep 21, 2006
      Thank you very much.

      --- In phpexperts@yahoogroups.com, masudul haque <masudkuet@...>
      wrote:
      >
      > you can use query of the following type.....................
      >
      > SELECT * FROM $table WHERE jobnumber='$jobnumber' AND
      startdate='$startdate' AND (CURDATE() + INTERVAL 3 DAY)<=db_date;
      >
      >
      > alcarterguitars <alcarterguitars@...> wrote:
      > I am new to php and am looking for some help with a date
      comparison.
      > I have inserted the code below. I have a form and want the user to
      > input a JobNumber and a date for submittal. I then want to compare
      > that date and job number to the data in the MySQL database. If both
      > match I then want another check run to compare dates. I want to
      only
      > give access to the hupd.php file 3 days before the date in the
      > database (This is very important and can't quite figure out how to
      do
      > it). Thanks very much and let me know if you need more information.
      >
      > <?php
      >
      > $jobnumber = $_POST['jobnumber'];
      > $startdate = $_POST['startdate'];
      > $todays_date = date("Y-m-d");
      >
      > include 'db.inc';
      >
      > // Connect to the MySQl database Server
      > mysql_connect($hostName,$username,$password);
      >
      > // Select a MySQL database
      > mysql_select_db($databaseName) or die ("Unable to select the
      > database");
      >
      > // Build Query
      > $result = mysql_query("SELECT * FROM $table where jobnumber
      > = '$jobnumber' AND startdate = '$startdate'");
      >
      > $num = mysql_result($result,0);
      >
      > if (!$num) {
      > echo "<h3>Enter Job Number and Start Date</h3>
      >
      > <form action = '$_SERVER[PHP_SELF]' method ='post'>
      > JobNumber:   <input type = 'text' name='jobnumber'><br>
      > StartDate:      <input type = 'text'
      > name='startdate'><br><br>
      > <input type = 'submit' value= 'submit'>
      > </form>";
      >
      > } else {
      > echo "<h1> Welcome Technician</h1>";
      > include 'hupd.php';
      > }
      > ?>
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.