這樣做是從「批准」字段的值爲「0」的數據庫中獲取數據。顯示錶單。現在我們要做的是在點擊「批准」按鈕時將'批准'字段的值更新爲'1'。我認爲IF條件存在一些問題或某些問題,不確定。連接到數據庫沒有問題。或者我需要關閉數據庫連接或提交或更新發生,不知道。謝謝您的幫助。更新表單提交中的數據庫字段 - PHP
require("dbconn.php");
// get the form data and store it in the database
// show database data
$query="SELECT * FROM page where approve=0";
$result=mysql_query($query);
if ($result)
{
print "<b>Approval pending for below listings.</b><br><br>";
while($row = mysql_fetch_array($result))
{
echo '<form name="submit_form" action="" method="post">';
$page_url = $row['page_url'];
$contact_number = $row['contact_number'];
$description = $row['description'];
$category = $row['category'];
$address = $row['address'];
$business_name = $row['business_name'];
echo "<input type=\"text\" name=\"business_link\" value=\"$page_url\" readonly><br/>";
echo "<input type=\"text\" name=\"contact_number\" value=\"$contact_number\" readonly><br/>";
echo "<input type=\"text\" name=\"description\" value=\"$description\" readonly><br/>";
echo "enter code here`<input type=\"text\" name=\"category\" value=\"$category\" readonly><br/>";
echo "<input type=\"text\" name=\"address\" value=\"$address\" readonly><br/>";
echo "<input type=\"text\" name=\"business_name\" value=\"$business_name\" readonly><br/>";
echo "<input type=\"Submit\" Value=\"Approve\" name=\"submit\"/>";
echo "</form>";
echo "<hr><br>";
if($_POST['submit_form'] == "submit")
{
mysql_query("UPDATE page SET approve='1' WHERE business_name='$business_name' AND contact_number='$contact_number' AND page_url='$page_url' AND description='$description' AND address='$address' AND category='$category'");
echo "Thank you!";
}
}
}
else
{
print mysql_error();
}
你確定它正在查詢嗎?它是否迴應了「謝謝」?如果是這樣,請嘗試回顯查詢本身並在phpMyAdmin或SQL工作臺中手動運行它。這將幫助您識別查詢中的錯誤。 – Apropos
從該表單看來,您並未提交任何名稱爲「submit_form」的東西。這是你的表單的名稱,但這不會作爲後期變種。 – Apropos