Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

get value into array

$
0
0

I have a sql query  that gets all the events from a specified month and should put the values into an array.print _r shows the values are being pulled from the database.

I can't get this to work.

Any suggestions appreciated.

Code

$events = array();
global$wpdb;
 
echo $month;
echo $year;
 
$query=("SELECT title, DATE_FORMAT(event_date,'%Y-%m-%e')AS event_date FROM sw_appointments  WHERE YEAR(event_date) = $year AND MONTH(event_date) = $month");
 
$result = $wpdb->get_results($query,ARRAY_A);
print_r($result);
foreach( $result as $results ) {
        
        $events=$results->event_date;
        echo $events;
        
 }
    

Viewing all articles
Browse latest Browse all 13200

Trending Articles