LAMP堆栈 - 更新HTML表 - 不映射到/从DB
你好,我有一个基本的HTML表单的Index.htmlLAMP堆栈 - 更新HTML表 - 不映射到/从DB
<html> <body>
<form action="update.php" method="POST">
Department: <input type="text" name="department"><br><br>
Subname: <input type="text" name="subname"><br><br>
Labels: <input type="text" name="labels"><br><br>
Pagerduty: <input type="text" name="pagerduty"><br><br>
Description: <input type="text" name="description"><br><br>
<input type="submit" value="Submit" name="submit">
</form>
</body>
</html>
在提交以下PHP脚本执行与细节来更新我的DB 。 update.php
<?php $hostname = "localhost";
$username = "root";
$password = "xxxxxxxxxxx";
$db = "dora";
$dbconnect=mysqli_connect($hostname,$username,$password,$db);
if ($dbconnect->connect_error) {
die("Database connection failed: " . $dbconnect->connect_error);
}
if(isset($_POST['submit'])) {
$department=$_POST['department'];
$subname=$_POST['subname'];
$labels=$_POST['labels'];
$pagerduty=$_POST['pagerduty'];
$description=$_POST['description'];
$query = "INSERT INTO dora (department, subname, labels, pagerduty, description)
VALUES ('$department', '$subname', '$labels', '$pagerduty', '$description')";
if (!mysqli_query($dbconnect, $query)) {
die('An error occurred when submitting your review.');
} else {
echo "Thanks for your review.";
}
}
?>
然后我想另一个页面显示来自DB main.html中
<html> <body>
<?php
$hostname = "localhost";
$username = "root";
$password = "xxxxxxxx";
$db = "dora";
$dbconnect=mysqli_connect($hostname,$username,$password,$db);
if ($dbconnect->connect_error) {
die("Database connection failed: " . $dbconnect->connect_error);
}
?>
<table border="1" align="center">
<tr>
<td>Department</td>
<td>Subname</td>
<td>Labels</td>
<td>Pagerduty</td>
<td>Description</td>
</tr>
<?php
$query = mysqli_query($dbconnect, "SELECT * FROM dora")
or die (mysqli_error($dbconnect));
while ($row = mysqli_fetch_array($query)) {
echo
"<tr>
<td>{$row['department']}</td>
<td>{$row['subname']}</td>
<td>{$row['labels']}</td>
<td>{$row['pagerduty']}</td>
<td>{$row['description']}</td>
</tr>\n";
}
?>
</table>
</body>
</html>
一切内容的HTML表格由两列除了正常工作不映射即Subname & Labels
我已经仔细检查了我的代码,但我无法发现错误,任何人都可以帮我吗?
我已经重新启动HTTPS等,但似乎没有任何工作:(
DORA SCHEMA
MariaDB的从多拉[多拉]>显示列;
+-------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| TAB_ID | int(11) | NO | PRI | NULL | auto_increment |
| department | varchar(200) | YES | | NULL | |
| subname | varchar(200) | YES | | NULL | |
| labels | varchar(200) | YES | | NULL | |
| pagerduty | varchar(200) | YES | | NULL | |
| description | varchar(200) | YES | | NULL | |
+-------------+--------------+------+-----+---------+----------------+
从结果我的表
Department Subname Labels Pagerduty Description 1 4 5
1 4 5
sdfsdf adfasdfad adfadfadfa
回答:
我测试了你的代码它工作正常。唯一的区别是即时通讯使用InnoDB应该是相同的。请尝试以下操作:
1更改这些列名称。
2重新创建您的数据库。
3确保没有trigers设置两个列木板
以上是 LAMP堆栈 - 更新HTML表 - 不映射到/从DB 的全部内容, 来源链接: utcz.com/qa/265625.html