Forum Moderators: coopster
if(isset($_POST['report'])){
$date = clean($_POST['date']);
$sql = "SELECT * FROM log WHERE date = '$date' ORDER BY id ASC";
$result = mysql_query($sql) or die(mysql_error());
$num_rows = mysql_num_rows($result);
if ($num_rows > 0) {
$balanceArray=get_balance();
$balance = $balanceArray['balance'];
$colour = $balanceArray['colour'];
$myarray = array();
while ($row = mysql_fetch_assoc($result)) {
$id = $row['id'];
$ref = $row['ref'];
$in = $row['in'];
$out = $row['out'];
$detail = $row['detail'];
$myarray[] = array('id' => $id, 'ref' => $ref, 'inn' => $in, 'out' => $out, 'detail' => $detail);
}
echo json_encode($myarray);
} else {
$arr = array("result" => "error");
echo json_encode($arr);
}}
$.each(response, function(key, val) {
$("#report").append('<tr><td>' + val.ref + '</td><td>' + val.inn + '</td><td>' + val.out + '</td><td>' + val.detail + '</td></tr>');
});
$("#report").append('<p>Total:' + response.balance + '</p>');
$(".main-content").html("<table id=\"till\"><thead><tr><th>Reference</th><th>In</th><th>Out</th><th>Details</th></tr></thead><tbody>");
$.each(response, function(key, val) {
$("#till tbody").append('<tr><td id="' + key + '">' + val.ref + '</td><td>' + val.inn + '</td><td>' + val.out + '</td><td>' + val.detail + '</td></tr>');
});
$("#till tbody").append('<tr><td colspan=\"4\">Total Spent:' + val.balance + '</td></tr>');
$("#till tbody").append('</tbody></table>');
$myarray = array();
$myarray[] = array('balance' => $balance, 'colour' => $colour);
while (...) {
$.each(response, function(key, val) {
if (key == 0) return;
$("#till tbody").append('<tr><td id="' + key + '">' + val.ref + '</td><td>' + val.inn
+ '</td><td>' + val.out + '</td><td>' + val.detail + '</td></tr>');
}); response[0].balance