An easier way would be to use the built-in MySQL functions directly. That way,
you avoid issues with date-format conversions between PHP and MySQL.

Look at:

You code then becomes:

switch ($type) {
case "today": $sql = "... where field = current_date()"; break;
case "tomorrow": $sql = "... where field = (INTERVAL 1 DAY + current_date())";
case "week": $sql = "... where field = (INTERVAL 1 WEEK + current_date())";
default: die("Don't know what to do?");



------ Original Message ------
Received: Mon, 28 Apr 2008 01:32:31 PM CDT
From: Nasreen Laghari <[EMAIL PROTECTED]>
Subject: [PHP-DB] Query Criteria

Hi All,
I need help in below coding as it is not working.
What I'm trying to do here, if $type contains "today" value then bring all
record which has today's date, If $type contains "tomorrow" bring all
tomorrow's record. 
Do you think below coding is correct? becuase when I run this query I get
exception but if I place only one $query and outside of if.. else  the same
query runs without errors.
Thank you for your help

$date = date("d/m/y");

  $query = "SELECT * FROM gig where gig_Date= $date";
else if($type=="tomorrow")
  $tomorrow  = mktime(0, 0, 0, date("m")  , date("d")+1, date("Y"));
  $query = "SELECT * FROM gig where gig_Date= $tomorrow";

else if($type=="week")
  $week  = mktime(0, 0, 0, date("m")  , date("d")+6, date("Y"));
  $query = "SELECT * FROM gig WHERE g.gig_Date <= ".$date." OR g.gig_Date

$result = mysql_query($query)or die(mysql_error());

  return $result;

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to