Jump to content

Retrieve date with query


Lassie

Recommended Posts

I am developing a calendar for use on a wordpress site.

I have a series of events and need to retrieve all the events in a selected month and get them into the $events array

I am getting no results from my query and no errors.

My table has title, event_date,time.notes,post code.

Only the first two fields are populated at the moment

The event_date is stored as DATE.

After retrieving the data $year,$month and $events is passed to a function to draw the calendar and show the months events.

 

$events = array();
global $wpdb;
$query=("SELECT title, DATE_FORMAT(event_date,'%Y-%m-%D')FROM sw_appointments WHERE event_date LIKE '$year-$month%'");
 
$result = $wpdb->get_results($query);
print_r($result);
 
while($row = mysql_fetch_assoc($result)) {
 
$events[$row['event_date']][] = $row;
 
        /* verify that the query gets results. 
   Also generates a list of this months events */
    echo $row['title']." ----- ".$row['event_date'];
    echo "<br />";
    
}
Any suggestions appreciated
Link to comment
https://forums.phpfreaks.com/topic/285144-retrieve-date-with-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.