我需要您对我正在尝试制作的代码的帮助。当医生需要在每个行中保存数据时,我需要显示一个包含需要可编辑的行的表。
我正在尝试制作的表格是这样的儿童免疫计划:
所以,我需要将数据保存在每个麻疹示例中。当孩子有 1 年(12 个月)等时.. 我只能在 jeditable 中进行一行编辑...你能帮我吗?
这是我用来节省价格的代码:
<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>
编辑: 这里是数据库:
<?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;
?>
这里是保存插入数据的脚本:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('.honorario_1').editable('includes/savehonorario.php?type=honorario');
});
</script>
在这里刷新可编辑:
<script type="text/javascript">
setInterval(function() {
$.get('includes/honorario.php?id_paciente=<?php echo $id_paciente; ?>', function(data) {
$('#honorario').html(data);
});
}, 1000);
</script>