重定向到另一个页面

时间:2016-10-30 23:51:32

标签: php html mysql

大家好我有这个问题我无法解决的问题是我有两个按钮一个用于删除而另一个用于编辑,删除工作完美无缺,但编辑按钮似乎无法使其重定向到一个php文件+如何在重定向到另一个页面时用编辑按钮获取会议名称不知道这是我的代码

 <table class="table table-striped custab" >
  <thead>
    <tr>
      <th>Title</th>
      <th>Chairman</th>
      <th>Summary</th>
      <th> Date &   Time</th>
    </tr>
    <?php

        $findMeetings = "SELECT * FROM `meeting` WHERE chairman='".$name."'";

        $result = mysqli_query($db, $findMeetings);

        $numRows = mysqli_num_rows($result);

        if($numRows == 0){

            $empty = "<div class='alert alert-danger'>You are currently managing no meetings!</div>";

        }
        else{

            $x = 0;

            while($rows = mysqli_fetch_array($result)){

                $title = $rows['title'];
                $chairman = $rows['chairman'];
                $date = $rows['time'];
                $summary = $rows['summary'];

                $meeting = "
                <tr>
                <th>".$title."</th>
                <th>".$chairman."</th>
                <th>".$summary."</th>
                <th>".$date."</th>
                <th><form method='post'>
                    <input type='submit' class='btn btn-success' name='edit".$x."' value='Edit'/>
                    <input type='submit' class='btn btn-danger' name='delete".$x."' value='Delete'/>
                </form></th>
                </tr>
                ";

                echo $meeting;

                if(isset($_POST['delete'.$x.''])){

                    $query = "DELETE FROM meeting WHERE title='".$title."' LIMIT 1";

                    if($result = mysqli_query($db, $query)){

                        header("Location:managemeeting.php");

                    }

                }



            }

        }

    ?>

  </thead>
  <tbody>

  </tbody>
</table>

所以如何获取会议名称并将其传递给editmeeting.php导致有多个数据。

如果我这样做就像删除按钮没有发生这样的事情

if(isset($_POST['edit'.$x.''])){



                        header("Location:editMeeting.php");

                    }

1 个答案:

答案 0 :(得分:0)

您应该在每个提交按钮周围打<form>,并在每个action中指定<form>,以便根据{{1}按钮发布到正确的网址缠绕着。

然后在每个<form>中使用<hidden>字段将数据传递到您要发布到的网址。示例:<form>