dongroufan6846 2015-11-08 09:01
浏览 48
已采纳

在每一行上添加一个Accept和Decline按钮

I'm trying to add a button on every row which I already did. When I click update which updates a certain field on the database it doesn't work. When the button is clicked it's redirected to the approve.php file.

<?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');
}
}
?>
  • 写回答

1条回答 默认 最新

  • drvxclagw656708070 2015-11-08 09:17
    关注

    You are using method POST on your main file but in approve php you use $_GET ??

    according to your approve.php file, you can change your button to :

    "<td><a href='approve.php?Service_ID='.$row["Service_ID"].">Approve</a></td>"
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog