0
first of all, good afternoon. I have come to ask for your help because I have already spent a few hours looking for a solution and nothing.
I am trying to limit the SELECT from financial list to the value set in the select field within my form (HTML), for example "SELECT * FROM financial list LIMIT $search" Doing so:
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 fRegister is not an object.
That is, I’m not able to "collect" the value of select through the JSON value, if I match $search = 10, for example, it works normally. I don’t know if I was clear enough... I’m using PDO to make SQL Injection impossible through Prepared statements. http.get inside the java script to return the query is 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 http request get method within javascript without success, thus:
$scope.displayData = function()
{
$http.get("../sqlFunctions/selectForm.php", {
params: {
'registro': $scope.fRegistro
}
}).then(function(response){
$scope.entradas = response.data;
});
}
in 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>
I had found a solution but it was not as complete as yours. I marked your response as positive, thanks for the collaboration!
– Codeman