First, good afternoon. I have come to ask for your help because I have spent some hours looking for a solution and nothing.
I'm trying to limit the SELECT * from financial list to the value set in the select field inside my form (HTML), for example, "SELECT * FROM FINANCIAL LIST LIMIT $ search" Doing this:
include("../sqlConnection/connection.php");
$data = json_decode(file_get_contents("php://input"));
$search = $data->fRegistro;
$sql = "SELECT * FROM listafinanceira LIMIT $search";
$stmt = $PDO->prepare( $sql );
$stmt->bindParam(1, $search , PDO::PARAM_INT);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
echo json_encode($result);
but is returning the error stating that fRegistration is not an object.
That is, I am not able to "collect" the value of the select by the value in JSON, if I equate $ search = 10, for example, it works normally. I'm not sure if it was clear enough ... I'm using PDO to disable SQL Injection through prepared statements. The http.get inside the java script to return the query looks like this:
$scope.displayData = function()
{
$http.get("../sqlFunctions/selectForm.php",
{'fRegistro':$scope.fRegistro}
).then(function(response){
$scope.entradas = response.data;
});
}
I have tried to change the get method of http request into javascript without success, like this:
$scope.displayData = function()
{
$http.get("../sqlFunctions/selectForm.php", {
params: {
'registro': $scope.fRegistro
}
}).then(function(response){
$scope.entradas = response.data;
});
}
no html:
<select name="tipo" ng-model="fRegistro" ng-init="fRegistro='10'" ng-class="['uk-select','uk-form-width-small','uk-form-small']">
<option value="10">10</option>
<option>25</option>
<option>50</option>
<option>100</option>
</select>