它的作用是从“批准”字段的值为“0”的数据库中获取数据。显示表单。现在我们要做的是在单击“批准”按钮时将“批准”字段的值更新为“1”。我认为 IF 条件或某事存在一些问题,不确定。连接数据库没有问题。或者我是否需要关闭数据库连接或提交或进行更新,不确定。谢谢您的帮助。
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();
}