retrieving live data from $wpdb (1 post)

  1. adviceit
    Posted 2 years ago #

    I am trying to run some live data feeds into my page. I am using the global $wpdb variable to access the custom tables and data which works great.

    However I have a timer running which re-runs the $wpdb->get_results() and rewrites the results into a div. But after the inital run through the data is not updated as if the $wpdb is not updated.

    The function I have is:

    	global $wpdb;
    	$total = 0;
        	$sales = $wpdb->get_results( "SELECT NET_AMOUNT FROM wp_dailysales");
    	foreach($sales as $sale)
    	    $total += $sale->NET_AMOUNT;
    	$total = $total;

    If I refresh the page it pulls in the correct data, just not on the timer. Is there a function that I am missing?



Topic Closed

This topic has been closed to new replies.

About this Topic