Created
October 24, 2013 21:18
-
-
Save underdown/7145169 to your computer and use it in GitHub Desktop.
Push X-Cart sales stats to json format for geckoboard (polling - (number and secondary number)- needs some authentication)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $username = "username"; | |
| $password = "pass"; | |
| $hostname = "localhost"; | |
| $db = "dbname"; | |
| //connection to the database | |
| $dbhandle = mysql_connect($hostname, $username, $password) | |
| or die("Unable to connect to MySQL"); | |
| //select a database to work with | |
| $selected = mysql_select_db($db, $dbhandle) | |
| or die("Could not select db"); | |
| $result = mysql_query("SELECT SUM(total) FROM `xcart_orders` WHERE `date` BETWEEN UNIX_TIMESTAMP(SUBDATE(current_date, INTERVAL 30 DAY)) AND UNIX_TIMESTAMP(SUBDATE(current_date, INTERVAL 1 DAY)) AND `status` LIKE 'P' OR 'C'"); | |
| $row = mysql_fetch_row($result); | |
| $result2 = mysql_query("SELECT SUM(total) FROM `xcart_orders` WHERE `date` BETWEEN UNIX_TIMESTAMP(SUBDATE(current_date, INTERVAL 60 DAY)) AND UNIX_TIMESTAMP(SUBDATE(current_date, INTERVAL 31 DAY)) AND `status` LIKE 'P' OR 'C'"); | |
| $row2 = mysql_fetch_row($result2); | |
| if($row) | |
| if(!isset($row[0])) $row[0] = "0"; | |
| if(!isset($row2[0])) $row2[0] = "0"; | |
| echo "{\"item\":[{\"text\":\"This Month\",\"value\":\"".$row[0]."\"},{\"text\":\"Last Month\",\"value\":\"".$row2[0]."\"}]}"; | |
| ?> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
technically this is 30 days and not a month