I have a conection.php that connects to the DB and queryTickets.php :
<?php
header('Access-Control-Allow-Origin: *');
date_default_timezone_set("Chile/Continental");
**// Including database connections**
require_once 'conection.php';
**// mysqli query to fetch all data from database**
$query = "SELECT rut, numero FROM Tickets WHERE servicio_id = $_POST['servicio_id']";
$result = mysqli_query($con, $query);
$arr = array();
if(mysqli_num_rows($result) != 0) {
while($row = mysqli_fetch_assoc($result)) {
$arr[] = $row;
}
}
**// Return json array containing data from the databasecon**
echo $json_info = json_encode($arr);
?>
I have the problem in Query in WHERE
because I want to send the parameter from the AngularJS driver because of the data I get from a login ... (another WS). p>
The question is: how can I do it?
In angularJS it should be as follows:
$http({
method: 'POST',
url: 'http://localhost/Paneldetencion/app/php/consultaTickets.php',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
data: {
servicio_id: 38
}
})
.then(function(data) {
var dat = data.data;
$scope.tickets = [];
for (var i = 0; i < dat.length; i++) {
dat[i]
var ticket = {
numero: dat[i].numero,
rut: dat[i].rut,
};
$scope.tickets.push(ticket);
}
}
Is the number an integer, how should it be parsed?
error: Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /Applications/XAMPP/xamppfiles/....php on line 7