我試圖將生成的表單發佈到第二個文件進行進一步處理,但只有最後一個條目發送到第二個文件。如何將循環中的所有信息發送到第二頁?此外,$_POST['STAMP']
條目未被髮布。我是否需要一種不同的方法來檢索DB數據?如何提交一個php中的所有字段,而標籤
<!DOCTYPE html>
<html>
<body>
<form action="payc.php" method="post">
Pay Range
<input type="date" name="start">
<input type="date" name="stop">
<input type="submit">
</form>
</body>
</html>
<?php
$servername = "localhost";
$username = "user";
$password = "Pass";
$dbname = "DB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM TIME WHERE STAMP BETWEEN '". $_POST['start']."' AND '".$_POST['stop']."'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "<form action=\"test.php\" method=\"post\">";
while($row = $result->fetch_assoc()){
$duration=(($row['T_OUT']-$row['T_IN'])/60)/60;
echo "<fieldset><input type=\"hidden\" name=\"date\" value=\"".$_POST['STAMP']."\"><input name=\"EMP\" type=\"text\" value=\"". $row['EMP']. "\"><input name=\"time\" type=\"text\" value=\"" . $duration. "\"><input name=\"ITEM\" type=\"text\" value=\"" . $row['ITEM']. "\"><input name=\"NOTE\" type=\"text\" value=\"" . $row['NOTE']. "\"></fieldset>";
}
echo "<input type=\"submit\">";
echo "</form>";
} else {
echo "0 results";
}
foreach($_POST as $results){
var_dump($results);
}
$conn->close();
?>
所有的「行」在你的嘗試中相互覆蓋。你必須使用類似的東西:' arkascha
我該如何解決這個問題? – Elegance
@arkascha我不理解。你能爲我詳細說明嗎? :) – Elegance