【发布时间】:2021-02-20 23:01:22
【问题描述】:
我创建了一个使用 POST 作为方法的表单。但在表格内部有一个表格需要使用该表格填写的数据库值进行更新。 问题是,当我在表中调用所需的 php 文件时。 调用之后的一切都消失了。所有标签,提交。甚至是页脚。 有什么理由吗? 这是我的代码
<section>
<div class="formaGasto">
<form action="php/addIngreso.php" method="POST" id="formulario">
<h3>Ingresos de la vivienda</h3>
<br>
<br>
<label id="labels" for="name">Nombre del ingreso: </label>
<input id="inputs" type="text" name="name" id="name">
<br>
<br>
<label id="labels" for="value">Valor del ingreso: </label>
<input id="inputs" type="number" name="value" id="value">
<br>
<br>
<div class="tableFlow">
<table class="table table-striped table-sm" id="js">
<tr>
<th>Nombre del ingreso</th>
<th>Valor</th>
</tr>
THIS IS THE CULPRIT **<?php require_once 'php/showInfo.php';?>**
IF I REMOVE IT, EVERYTHING IS BACK
<br>
</table>
</div>
<br>
<input type="submit" value="Nuevo" name="carga" id="new" class="boton" onclick="addToTabla()">
<button type="button" class="boton" data-toggle="modal" data-target="#exampleModalCenter">
Guardar
</button>
</form>
</div>
</section>
<footer>
<img src="img/republicaFuturo.png" id="futuro" alt="">
<img src="img/govcoBlue.png" id="govco" alt="">
</footer>
这是我的查询文件
<?php
include 'db.php';
$sql = "SELECT nombre, valor FROM concepto_ingreso";
$send = $connect->prepare($sql);
$send->execute();
foreach ($send as $value) {
print "<tr>";
print "<td> $value[0] </td>";
print "<td> $value[1] </td>";
print "</tr>";
}
print "</table>";
$connect = null;
?>
【问题讨论】:
-
您可能还想从 showInfo.php 文件中删除打印表格指令 - 这会给您一个不平衡的表格元素,这可能会导致一些问题。
-
建议 - 获取数据时,获取数据。在您进入视图之前不要打印它。
-
尝试开启报错