I am working with JEditable but in json select I have an issue, because in the console show me the json but in the page the select input is empty.
Here the captures:
Here the code:
require($_SERVER['DOCUMENT_ROOT'] . '/config.php');
$result = $conn->query("SELECT id_user_details, first_name, last_name
FROM users");
$return_arr = [];
while($row = $result->fetch(PDO::FETCH_ASSOC)) {
$return_arr[] = array(
$row['id_user_details'] => $row['first_name'].' '.$row['last_name'],
);
};
$conn = null;
header('Content-type: application/json');
echo json_encode($return_arr);
Here the javascript:
$(".status").editable("include/users.php", {
type : "select",
loadurl : "include/select.php",
submit : "OK",
submitdata : {pk : $(this).attr('id'), _as_csrf_token: token},
indicator : '<img src="images/spinner.gif" />',
style : "inherit"
});
The where the select show if the client need to change the user
<td>
<a href="javascrip:void(0);" class="status" id="<?php echo $row['id_ch']; ?>" style="font-size:11px;">
<?php echo $row['doctor']; ?>
</a>
</td>
Well I finally did it!
I change the previously code:
require($_SERVER['DOCUMENT_ROOT'] . '/config.php');
$result = $conn->query("SELECT id_user_details, first_name, last_name
FROM users");
$return_arr = [];
while($row = $result->fetch(PDO::FETCH_ASSOC)) {
$return_arr[] = array(
$row['id_user_details'] => $row['first_name'].' '.$row['last_name'],
);
};
$conn = null;
header('Content-type: application/json');
echo json_encode($return_arr);
To this one:
require($_SERVER['DOCUMENT_ROOT'] . '/config.php');
$result = $conn->query("SELECT id_user_details, first_name, last_name
FROM users");
while($row = $result->fetch(PDO::FETCH_ASSOC)) {
$id_user_details = $row['id_user_details'];
$array[$id_user_details] = $row['first_name'].' '.$row['last_name'];
};
$conn = null;
header('Content-type: application/json');
print json_encode($array);