我想要一些输入,如何从我的代码中的表单执行更新查询我确定我把它放在错误的地方我没有收到任何错误但它没有更新我相信它在代码中的位置?我想我需要一个循环来捕捉文本框的更新......对吗?有没有更好的方法让我看看这个?我打算将更新发送到一个新页面,但认为最好将其保留在一个页面中,这样您就可以看到我在哪里 REM 提交代码。phpmyadmin 如何更新文本框?我假设他们使用java脚本会更好吗?任何建设性的意见将不胜感激。
<html>
<?php
session_start();
?>
<head>
<basefont face="Arial">
<title>Search</title>
</head>
<body>
<?php
// include the page Header
include('header.php');
?>
<?php
$today = date("n/j/Y");
// set database server access variables:
$host = "localhost";
$user = "test";
$pass = "test";
$db = "test";
// open connection
$connection = mysqli_connect($host, $user, $pass, $db);
if (mysqli_connect_errno($connection)) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// create query
$query = "SELECT * FROM testingqa1160";
$result = mysqli_query($connection, $query);
$subbox = '<input type="Submit" value="Update" name="Submit">';
// echo '<form name="release" action="somepage.php" method="get">';
if (mysqli_num_rows($result) > 0) {
// print them one after another
echo "<center>";
echo "<center><FONT SIZE=18>";
echo " Material to be tested </font>";
echo "</center>";
echo "<center><table cellpadding=1 border=1>";
//echo "<tr>";
echo "<center>";
echo "<td><center>"."ID"."</center></td>";
echo "<td><center>"."Material"."</center></td>";
echo "<td><center>"."Test"."</center></td>";
echo "<td><center>"."Sample"."</center></td>";
echo "<td><center>"."Freq"."</center></td>";
echo "<td><center>"."STP"."</center></td>";
echo "<td><center>"."Release"."</center></td>";
echo "<td><center>"."Notes"."</center></td>";
echo "<td><center>"."LSL"."</center></td>";
echo "<td><center>"."USL"."</center></td>";
echo "<td><center>"."Lot"."</center></td>";
echo "<td><center>"."Results"."</center></td>";
echo "<td><center>"."Release"."</center></td>";
echo "<td><center>"."Date"."</center></td>";
echo "</center></tr>";
while($row = mysqli_fetch_row($result)) {
echo "<tr>";
$lottxtbox ='<input type="text" name="'.$row[0].'lotbox"size="6" value="'.$row[11].'">';
$restxtbox ='<input type="text" name="'.$row[0].'resbox" size="4" value="'.$row[12].'">';
$chbox = '<input type="checkbox" name="'.$row[0].'checkbox">';
echo "<td>".$row[0]."</td>";
// echo "<td>".$row[1]."</td>";
echo "<td><center>".$row[2]."</center></td>";
echo "<td><center>".$row[3]."</center></td>";
echo "<td><center>".$row[4]."</center></td>";
echo "<td><center>".$row[5]."</center></td>";
echo "<td><center>".$row[6]."</center></td>";
echo "<td><center>".$row[7]."</center></td>";
echo "<td><center>".$row[8]."</center></td>";
echo "<td><center>".$row[10]."</center></td>";
echo "<td><center>".$row[9]."</center></td>";
echo "<td><center>".$lottxtbox."</center></td>";
echo "<td><center>".$restxtbox."</center></td>";
echo "<td><center>".$chbox."</center></td>";
echo "<td>".$today."</td>";
// echo "<td>".$row[12]."</td>";
// echo "<td>".$row[13]."</td>";
echo "</tr>";
}
echo "</table></center>";
echo "</center>";
echo "<td><center>".$subbox."</center></td>";
echo "</form>";
}
else {
// no
// print status message
echo "<center><FONT SIZE=18>";
echo $_GET["mnumber"];
echo " Material is not found! </font>";
echo "</center>";
}
// free result set memory
mysqli_free_result($result);
// close connection
mysqli_close($connection);
?>
<?php
if(isset($_POST['Submit'])){//if the submit button is clicked
$update = $_POST['.$row[0]."lotbox"'];
$query="UPDATE Lot = $update where trace = '".$row[0]."'";
mysqli_query($connection,$query);
}
?>
<?php
// include the page footer
include('footer.php');
?>
</body>
</html>