你好,我有一個基本的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
愚蠢的問題,但...你證明:對於子名稱和標籤值確實得到(使用,也就是說,phpMyAdmin的)插入? – Rushikumar
+ --------- + |子名稱| + --------- + | | | | + --------- +是的,我檢查了,沒有任何進展:( – user3236169
只適用於這兩個領域,其他所有人都在工作 – user3236169