WordPress.org

Ready to get started?Download WordPress

Forums

retrieving live data from $wpdb (1 post)

  1. adviceit
    Member
    Posted 9 months 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:

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

    Thanks

    Simon

Reply

You must log in to post.

About this Topic