adviceit
Forum Replies Created
-
Forum: Plugins
In reply to: [SportsPress - Sports Club & League Manager] Problem with Event ImporterI’ll give that a go, them example CSV from the plugin the date format is:
mm/dd/yyyyForum: Hacks
In reply to: Retrieve Live Data from wpdbok sorted the 500 error was wrong reference to the wp-load.php not referencing he right location.
some : “../” needed.
Incase anyone else finds this post here are my scripts:
AJAX call in javascript:
$.ajax({ cache: false, url: "<?php bloginfo('template_url'); ?>/scripts/sales.php", success:function(data) { $("#sales-figure").html("<table><tr><td><br/><h2>Total for <?php echo date('F jS'); ?> is: </h2><H1 style='color:blue'>£"+data+"</h1></td><td id='sales-update-ticker'>Next Update: 1:00</td></tr></table>"); } });PHP file:
<?php require_once('../../../../wp-load.php'); global $wpdb; $results = $wpdb->get_var("SELECT SUM(NET_AMOUNT) FROM wp_dailysales"); if($results == "") { $results = 0; } echo $results ?>Thank you for your assistance guys.
Forum: Hacks
In reply to: Retrieve Live Data from wpdbHi
Ok, think i understand what you are saying. The page and the code is static, so the variables will be also.
So if i perform a GET from a new php page which returns the result that will work…
Ok cool, I have now added this to a new PHP page but keep getting Error 500 from the new PHP page, when i try and reference the $wpdb variable or its functions I get this error.
<?php include ('wp-load.php'); global $wpdb; $results = $wpdb->get_var($wpdb->prepare("SELECT SUM(NET_AMOUNT) FROM wp_dailysales")); echo $results; ?>I think it is because it doesn’t know what the object $wpdb is. So I tried all the includes I could think of without any joy.
Any ideas?
Forum: Hacks
In reply to: Retrieve Live Data from wpdbtried the resetdb() and this had the same result.
Thanks
Simon
Forum: Hacks
In reply to: Retrieve Live Data from wpdbfunction getSales() { $(".updatingSales", this.DOM_obj).removeClass("hideMe"); <?php global $wpdb, $total; $wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); $sales = array(); $total = 0; $sales = $wpdb->get_var($wpdb->prepare("SELECT SUM(NET_AMOUNT) FROM wp_dailysales")); ?> $panel = document.getElementsByClassName("panel-6")[0]; $content = $panel.getElementsByTagName("span")[0]; $content.innerHTML = ""; $content.innerHTML = "<table><tr><td><br/><h2>Total for <?php echo date('F jS'); ?> is: </h2><H1 style='color:blue'>£<?php echo $sales ?></h1></td><td id='sales-update-ticker'>Next Update: 1:00</td></tr></table>"; updatemins = 0; updatesecs = 59; setTimeout(function(){$(".updatingSales", this.DOM_obj).addClass("hideMe")}, 500); setTimeout(function(){getSales()}, 1*60*1000); clearTimeout(salesticker); salesticker = setTimeout(function(){updatesalesticker()}, 1000); }This is the complete function. it is self calling on the setTimeout after 1 minute.
Thanks
Simon
Forum: Hacks
In reply to: Retrieve Live Data from wpdbI have also tried
$wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); $sales = array(); $total = 0;To try and clear everything but still getting the old results.
Simon
Forum: Hacks
In reply to: Retrieve Live Data from wpdbHi Guys,
bcworkz you are correct that is the problem i am having I have tried the
$wpdb->flush();as well but got same result returned.I change the script to show what $sale->NET_AMOUNT was and it was still showing the old values after a manual change to the database. But if I refresh the page it shows the new value.
Wierd…