提交按钮后刷新 php 页面 - PHP - MySQL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14223230/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 06:52:49  来源:igfitidea点击:

Refreshing a php page after submit button - PHP - MySQL

phphtmlformssubmitpage-refresh

提问by RaGe10940

I have a page that needs to be constantly refreshed multiple times a minute. The page has is a echo'd php table. Preivew

我有一个页面需要每分钟不断刷新多次。该页面是一个 echo'd php 表。预览

The page loads perfectly fine, all is good, I have used the META tag HTML, I have used the header tag with the refresh function in PHP... and yet a problem arises :

页面加载得很好,一切都很好,我使用了 META 标记 HTML,我使用了带有刷新功能的页眉标记在 PHP 中......但出现了一个问题:

When I hit Start Session button the refresh stops. And the table bellow does does not get updated. So then I have to manually refresh the page. This is not the desired affect. Can some one explain to me how to refresh a page continually.

当我点击开始会话按钮时,刷新停止。并且下表不会更新。那么我必须手动刷新页面。这不是想要的效果。有人可以向我解释如何不断刷新页面。

Edit 1:

编辑1:

Code that makes the include of the session start

使包含会话开始的代码

foreach($result as $row)
    {
  echo "<tr>";
  echo "<td>" . $row['id'] . "</td>";
  echo "<td> <a href=student.php?anum=" . $row['anum'] . " target='_blank'>" .$row['anum'] . " </a></td>";
  echo "<td>" . $row['first'] . "</td>";
  echo "<td>" . $row['last'] . "</td>";
  echo "<td>" . $row['why'] . "</td>";  
  echo "<td>" . $row['comments'] . "</td>";
  echo "<td>" . $row['additional_req'] . "</td>";
  echo "<td>" . $row['signintime'] . "</td>";
  echo "
        <td>    <form action='counselor.php?id=" . $row['id'] . "' method='post' target='_new'>
                    <select name='namedrop'>
                        <option value=''>Counselor Name</option> 
                        <option value='Admin-John'>Admin - John</option>
                        <option value='Admin-Christine'>Admin - Christine</option>
                        <option value='Admin-Dawne'>Admin - Dawne</option>
                        <option value='Counselor-Cherie'>Counselor - Cherie</option>
                        <option value='Counselor-Tootie'>Counselor - Tootie</option>
                        <option value='Counselor-Debbie'>Counselor - Debbi</option>
                        <option value='FrontDesk-Delores'>Front Desk - Delores</option>
                        <option value='FrontDesk-Kiana'>Front Desk - Kiana</option>
                    </select>
            </td>

            <td> <input type='submit' name='submit' value='Start Session'></td>
            </form> </td>";
}

回答by Westy92

If you are looking to refresh the page when you click "Start Session", then you can edit your submit button to have this onClick listener. It should refresh the page.

如果您希望在单击“开始会话”时刷新页面,那么您可以编辑您的提交按钮以使用此 onClick 侦听器。它应该刷新页面。

<input type='submit' name='submit' value='Start Session' onClick="window.location.reload()" />

回答by Miles Grimes

Is it possible for you to use Javascript to achieve the desired effect? I don't know enough about what you're doing to determine whether that would clear your changes or not (my assumption here is: no).

是否可以使用Javascript来达到想要的效果?我不太了解您正在做什么,无法确定这是否会清除您的更改(我的假设是:否)。

If you are able to use Javascript, you could write a simple function which refreshes the page on an interval.

如果您能够使用 Javascript,您可以编写一个简单的函数来每隔一段时间刷新页面。

回答by soniccool

<form action="<?php echo $PHP_SELF; ?>" method="post">  

or

或者

<form action="thispage.php" method="post">