I have a function that returns me the values of a Grid in a Modal I call the function it does a Select in PHP and it returns me the data inside a Modal. But in addition to bringing this data I need to bring image names that are in another table but I can not do it.
JS
function GetUserDetails(id) {
// Add User ID to the hidden field for furture usage
$("#hidden_user_id").val(id);
$.post("ajax/readUserDetails.php", {
id: id
},
function (data, status) {
// PARSE json data
var user = JSON.parse(data);
// Assing existing values to the modal popup fields
$("#show_id").val(id);
$("#show_emailcontato").val(user.EmailContato);
$("#show_titulo").val(user.titulo);
$("#show_tipo_material").val(user.tipo_material);
$("#show_acabamento").val(user.acabamento);
$("#show_quantidade").val(user.quantidade);
}
);
// Open modal popup
$("#show_user_modal").modal("show");
}
readUserDetails.php
// include Database connection file
include("db_connection.php");
// check request
if(isset($_POST['id']) && isset($_POST['id']) != "")
{
// get User ID
$user_id = $_POST['id'];
// Get User Details
$query = "SELECT * FROM TblPedidos ped LEFT JOIN TblCadastros cli ON ped.TipoCadastro = cli.TipoCadastro AND ped.idcliente = cli.id WHERE ped.id = '$user_id'";
if (!$result = mysqli_query($con, $query)) {
exit(mysqli_error($con));
}
$response = array();
if(mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
$response = $row;
}
}
else
{
$response['status'] = 200;
$response['message'] = "Data not found!";
}
// display JSON data
echo json_encode($response);
}
else
{
$response['status'] = 200;
$response['message'] = "Invalid Request!";
}
I need to insert this query in readUserDetails.php
$query = "SELECT * FROM 'tblpedidos_upload' WHERE idpedido = '$userid' ";
if (!$result = mysqli_query($con, $query)) {
exit(mysqli_error($con));
}