0
我試圖在每一行上添加一個按鈕,我已經做了。當我點擊更新數據庫上的某個字段時,它不起作用。當按鈕被點擊時,它被重定向到approve.php文件。在每一行添加一個接受和拒絕按鈕
<?php
$con=mysqli_connect("localhost","root","","rabco");// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM service_request");
echo "<table border='1'>
<tr>
<th>Service ID</th>
<th>Service Type</th>
<th>Schuduled Date</th>
<th>Scheduled Time</th>
<th>Client Reference
<th>Client ID</th>
<th>Admin ID</th>
<th>Special Instructions</th>
<th>Status</th>
<th>Approve</th>
<th>Decline</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Service_ID'] . "</td>";
echo "<td>" . $row['Service_type'] . "</td>";
echo "<td>" . $row['Sched_date'] . "</td>";
echo "<td>" . $row['Sched_time'] . "</td>";
echo "<td>" . $row['Client_reference'] . "</td>";
echo "<td>" . $row['Client_IDN'] . "</td>";
echo "<td>" . $row['Admin_IDN'] . "</td>";
echo "<td>" . $row['Special_instructions'] . "</td>";
echo "<td>" . $row['Request_status'] . "</td>";
echo "<td><form action='approve.php' method='POST'> <input type='hidden' name='accept' value='".$row["Service_ID"]."'/><input type='submit' name='submit' value='Approve'/></form></td>";
echo "<td><form action='decline.php' method='POST'><input type='hidden' name='decline' value='".$row["Service_ID"]."'/><input type='submit' name='submit' value='Decline'/></form></td>";
}
echo "</tr>";
echo "</table>";
mysqli_close($con);
?>
approve.php
<?php
$link = mysqli_connect("localhost", "root", "", "rabco");
if(isset($_GET["Service_ID"]))
{
$row_sr=$_GET["Service_ID"];
$sql="UPDATE service_request SET Request_status = 'Approved', Admin_IDN = '$_SESSION[Admin_ID]', Paid = 'Php 17,500', Balance = 'Php 32,500', Total_price = 'Php 50,000' WHERE Service_ID = '$row_sr'";
$result=mysqli_query($sql);
mysqli_query($link,$result);
if($result==1)
{
header('location: adminpage-sr.php');
}
}
?>
仍然沒有運氣爵士。 :(((( –
你是否改變按鈕或更改approve.php? 如果你不想改變按鈕,只需將您的approve.php中的所有$ _GET [「Service_ID」]更改爲$ _POST [「Service_ID」],我認爲這將工作 –
我改變了按鈕根據您的代碼 –