Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- +----+------------+----------+-----------------+----------
- | ID | DATE | Time | Create | Delete | Product |
- +----+------------+----------+-----------------+---------+
- | 1 | 03/12/2017 | 09:00:00 | 28 | 1264 | 59 |
- <?php
- $DB_NAME = 'testDB';
- $DB_HOST = 'localhost';
- $db_port = '3306';
- $DB_USER = 'test';
- $DB_PASS = 'mysql';
- $mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);
- if (mysqli_connect_errno()) {
- printf("Connect failed: %sn", mysqli_connect_error());
- exit();
- }
- $result = $mysqli->query('Select * from (SELECT * FROM Stats ORDER BY id DESC LIMIT 48)t ORDER BY id ASC');
- $rows = array();
- $table = array();
- $table['cols'] = array(
- array('label' => 'Time', 'type' => 'string'),
- array('label' => 'ProductCreate', 'type' => 'number'),
- array('label' => 'ProductDelete', 'type' => 'number'),
- array('label' => 'ProductRenew', 'type' => 'number')
- );
- foreach($result as $r) {
- $temp = array();
- $temp[] = array('v' => (string) $r['Time']);
- $temp[] = array('v' => (int) $r['Create']);
- $temp[] = array('v' => (int) $r['Delete']);
- $temp[] = array('v' => (int) $r['Renew']);
- $rows[] = array('c' => $temp);
- }
- $table['rows'] = $rows;
- // convert data into JSON format
- $SubsStats = json_encode($table);
- echo $SubsStats;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement