Pregunta

I need your help with this code I am trying to make. I need to show a table with rows which need to be editables when the doctor need save data in each one.

the table I am trying to make is a Child immunization schedule like this:

enter image description here

so, I need to save the data in per example measles. when the child have 1 year(12 months) and so on.. I only can do in one row edit in jeditable... can you help me with this?

here the code I user to save price:

<table class="table">
<thead>
<tr>
<th><?php $translate->__('Date'); ?></th>
<th><?php $translate->__('Income'); ?></th>
</tr>
</thead> 
<tbody>
<?php 
$sql = $conn->prepare("SELECT id, DATE_FORMAT(start, '%d %M %Y') AS start, honorario FROM CITAS where id_paciente = $id_paciente order by id DESC LIMIT 1");
$sql->execute();
while($row = $sql->fetch(PDO::FETCH_ASSOC)) {
?>
<tr>
<td><?php echo $row['start']; ?></td>
<td id="<?php echo $row['id']; ?>" class="honorario_1"><?php echo $row['honorario']; ?>
</td>
</tr><?php } ?>
</tbody>

EDITED: here the db:

<?php 
include_once("conf.php");
  $type = (isset($_GET['type'])) ? $_GET['type'] : "";
  $value = (isset($_POST['value'])) ? $_POST['value'] : "";
  $id = (isset($_POST['id'])) ? $_POST['id'] : "";
  if($type == "honorario") {
    $sql = "UPDATE CITAS SET honorario = :honorario where id ='$id'";
    $stmt = $conn->prepare($sql);
    $stmt->bindParam(':honorario', $value, PDO::PARAM_STR);
    $stmt->execute();
  };
  $type = (isset($_GET['type'])) ? $_GET['type'] : "";
  $value = (isset($_POST['value'])) ? $_POST['value'] : "";
  $id = (isset($_POST['id'])) ? $_POST['id'] : "";
  if($type == "honorario") {
    $sql = "UPDATE CITA_HONO SET honorario = :honorario where id_ch ='$id'";
    $stmt = $conn->prepare($sql);
    $stmt->bindParam(':honorario', $value, PDO::PARAM_STR);
    $stmt->execute();
  };
   print $value;                            
?>

here the script to save the data inserted:

<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('.honorario_1').editable('includes/savehonorario.php?type=honorario');
});
</script>

here to refresh the editable:

<script type="text/javascript">
setInterval(function() {
$.get('includes/honorario.php?id_paciente=<?php echo $id_paciente; ?>', function(data) {
$('#honorario').html(data);
});
}, 1000);
</script>
¿Fue útil?

Solución

I Resolve my question foloowing the next link editando-registros-de-una-tabla-con-jeditable-plugin-jquery

is very simple with the tutorial

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top