Jump to content

Help with date query


smti

Recommended Posts

Hi,

 

I need help pulling the value produced from an SQL query. I will explain, but here is the code:

 

<? include("includes/calendarconnection.inc.php"); ?>

<?
$today=date("m.d.y");



$result = mysql_query("SELECT * FROM $tbl_name where event_date=curdate()");
$eventstoday = mysql_num_rows($result);

echo $eventstoday;
echo "<br>";


if ($eventstoday==0){

echo "No events today, execute query for date in two days";


$newdate = mysql_query("Select date_add(curdate(), interval 2 day");
echo $newdate;


}
else {

// Retrieve data from database
$sql="SELECT * FROM $tbl_name where event_date=curdate() limit 1";
$result=mysql_query($sql);

// Start looping rows in mysql database.
while($rows=mysql_fetch_array($result)){

        echo $rows ['event_date'];
        echo "<br>";
        echo $rows ['event_title'];
        echo "<br>";
        echo $rows ['event_desc'];

}

// close while loop
}

// close connection
mysql_close();





 

Essentially, I need help with the IF statement:

 

if ($eventstoday==0){

echo "No events today, execute query for date in two days";


$newdate = mysql_query("Select date_add(curdate(), interval 2 day");
echo $newdate;


}

 

I need to execute the new date query and then echo the date provided by the query.  I tried just performing the query and then echoing, but this does not seem to work. Do I need to add a "fetch row query"? Any help you can provide would be much appreciated.

 

 

Thank You,

 

smti

Link to comment
https://forums.phpfreaks.com/topic/158643-help-with-date-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.