php require db php db new DB root accounts if isset _GET action _GET a

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
require('db.php');
$db = new DB('root', '', 'accounts');
if (isset($_GET['action']) && $_GET['action'] == 'start') {
$rs = $db->query('SELECT * FROM accounts ORDER BY number')
->resultset();
$keys_array = array('id', 'number', 'type', 'balance', 'description');
$i = 0;
foreach ($rs as $row) {
foreach ($keys_array as $key) {
$result[$i][$key] = $row[$key];
}
$i++;
}
$result = json_encode($result);
echo $result;
}
if (isset($_GET['number'])) {
$rs = $db->query('SELECT description FROM accounts WHERE number =' . $_GET['number'])->single();
echo $rs['description'];
}
/*echo '<pre>';
print_r($result);
echo '</pre>';*/
?>