Good. I have a DB calling vehicles, and I'm using PHP + Json for listing. But now I need to filter them out and I do not know how to do it. I was thinking about using the html but I'm not getting it either.
<?php
// header('Access-Control-Allow-Origin: *');
// header('Access-Control-Allow-Headers: *');
// header('Access-Control-Allow-Methods: GET, POST, PUT');
header('Content-Type: application/json');
$servername ="localhost";
$username ="root";
$password ="";
$dbname= "aula";
//Criar conexao
$conn = new MySQLi($servername,$username,$password,$dbname);
//Ver conexao
if($conn ->connect_error){
die("Connection failed: " . $conn->connect_error);
}
$res = mysqli_query($conn, "SELECT * FROM veiculo");
$datarequest = array();
if ((count($_REQUEST) > 0))
$datarequest = $_REQUEST;
$q = $datarequest['q'];
unset($datarequest['q']);
unset($_REQUEST['q']);
switch($q){
case 'carro':{
if ($res->num_rows > 0) {
while($row = mysqli_fetch_assoc($res))
$test[] = $row;
echo json_encode($test);
}
break;
}
}
?>