0
Good. I have a BD called vehicles, and I’m using PHP + Json for the listing. But now I need to filter them and I don’t know how to do it. I was thinking of using 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;
}
}
?>
What do you want to do specifically? If you just filter the results according to some criteria, you don’t just use one
WHERE
in query?– Jéf Bueno
wanted for example: write a tag and the tag appears
– Paulo
exactly paul
– Paulo