Support » Plugins » retrieving live data from $wpdb

  • 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?



  • The topic ‘retrieving live data from $wpdb’ is closed to new replies.