<?php
// gets select of jcards/insurance/reposession records in json for autocomplete
include 'includes/database.php';
$db=new MySQLDatabase();
$db->open_connection();
$sql = mysqli_query($db->connection, "SELECT regno, vehmod, chasis, imeino, CONCAT('[JC]-',jcno) as ltype FROM jcards LIMIT 100
					UNION SELECT regno, vehmod, chasis, pno, CONCAT('[IN]->',insno) FROM insrecs LIMIT 100
					UNION SELECT regno, vehmod, chasis, auct, CONCAT('[RO]-',repono) FROM reporders") or die (mysqli_error($db->connection) );
$larray = array();
while ($row = mysqli_fetch_array($sql, MYSQLI_ASSOC)){
    $row_array['value'] = $row['regno'].' - '.$row['vehmod'].' - '.$row['chasis'].' - '.$row['imeino'].' - '.$row['ltype'];
    array_push($larray, $row_array); 
    }
echo json_encode($larray);    
$db->close_connection();

?>