Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement