I have the following code:
<?php
require("config.inc.php");
$conn = new mysqli($host, $username, $password, $dbname);
if(!empty($_POST))
{
if(empty($_POST['usuario_rut_administrador']))
{
$response["success"] = 0;
$response["message"] = "Por favor rellene todos los campos solicitados";
die(json_encode($response));
}
$sql = "SELECT id_estacionamiento, nombre_estacionamiento, cantidad_cupos
FROM estacionamiento where usuario_rut_administrador=:usuariorutadministrador";
$query_params= array(':usuariorutadministrador' =>$_POST['usuario_rut_administrador']);
try{
$stmt = $db->prepare($sql);
$result = $stmt->execute($query_params);
} catch (PDOException $ex) {
$response["success"] = 0;
$response["message"] = "Database Error1. Please Try Again!";
die(json_encode($response));
}
$resulta = $conn->query($sql);
if ($resulta->num_rows >0) {
while($row[] = $resulta->fetch_assoc()) {
$tem = $row;
$json = json_encode($tem);
}
echo $json;
}
$row = $stmt->fetch();
if ($row) {
$response["success"] = 0;
$response["message"] = "si existe";
die(json_encode($response));
}
I receive a variable by post which I see if it is empty or not, then with that variable I want to make the selection to show me the data related to the variable, but here is the problem because it does not show any data nothing, just go blank.
when doing a SELECT * FROM estacionamiento
if it shows me the data, so it must be a problem with the variable, but I do not know what it can be.
I hope you can help me thanks:)