简体   繁体   English

如何强制浏览器读取更新的数据库信息?

[英]How do I force a browser to read updated database information?

Apologies if this question has been answered before, but I'm not sure how to easily describe it... 道歉,如果以前已经回答过这个问题,但是我不确定如何轻松地描述它...

I'm programming a system with PHP and MySql that will allow users that are logged in to build a sports team. 我正在使用PHP和MySql编程系统,该系统将允许登录的用户建立运动队。 I have system set up where a user "bids" on a player, and that player is added to their roster. 我建立了一个系统,在该系统中用户“出价”玩家,并将该玩家添加到他们的名册中。 The code that writes to the database is very simple and works fine: 写入数据库的代码非常简单并且可以正常工作:

mysql_query("UPDATE bidpool SET BidExpires='$newbidexpires' WHERE Player='$player'");
mysql_query("UPDATE bidpool SET CurrentBid='$bid' WHERE Player='$player'");
mysql_query("UPDATE bidpool SET TeamName='$NewTeamName' WHERE Player='$player'");

When I check the database, that information is entered correctly. 当我检查数据库时,该信息输入正确。

When I load up another page, where the team's updated roster is located, this is the code I use: 当我加载团队更新的花名册所在的另一页时,这是我使用的代码:

echo "<table>";
$result = mysql_query("SELECT * FROM bidpool WHERE TeamName='$teamname'");

$playerbid = 0;
$i = 0;

$num = mysql_numrows($result);

while ($i < $num) {

    $playerroster = mysql_result($result, $i, "Player");
    $playerbid = mysql_result($result, $i, "CurrentBid");
    $playerexpires = mysql_result($result, $i, "BidExpires");

    IF ($time > $playerexpires) {

        $playerexpires = "BID WON";
    }

    echo "<tr> 
                    <td width='30%'>$playerroster</td>
                    <td width='30%'>$playerbid</td>
                    <td width='30%'>$playerexpires</td>
                    </tr>";
    $i++;
}
echo "</table">;

The problem? 问题? Everything writes to the database just fine when there is a new bid. 当有新的出价时,一切都会写入数据库。 When I load the roster page up in Firefox, it shows the roster as it is in the database, with even the most recent changes shown only seconds later. 当我在Firefox中加载名册页面时,它将显示数据库中的名册,甚至最新更改也仅在几秒钟后显示。

When I load it in Safari and Chrome, however, it shows an old version of the roster. 但是,当我将其加载到Safari和Chrome中时,它会显示旧版本的花名册。 Even after I clear the browser cache, reset the browser, and even reboot my computer, it still shows an old version from the database. 即使在清除浏览器缓存,重置浏览器甚至重新启动计算机之后,它仍然显示数据库中的旧版本。

This type of system, with multiple users bidding on players over the course of several days, requires that players see the most recent bids and their recent roster changes as soon as possible. 这种类型的系统需要多个用户在几天内对玩家进行出价,因此要求玩家尽快看到最新的出价及其最近的名册更改。 But it won't work if the browser won't cooperate. 但是,如果浏览器不配合,它将无法正常工作。

If it makes any difference, the site is run on WordPress. 如果有什么不同,该站点可以在WordPress上运行。

What do you think I'm doing wrong here? 您认为我在这里做错了什么? Why does this system work flawlessly in one browser, but not another? 为什么该系统可以在一个浏览器上完美运行,但在另一个浏览器上却不能正常运行?

Thanks a bunch. 谢谢你

The problem is certainly a caching problem; 这个问题肯定是一个缓存问题。 you can test whether it's a client or Wordpress issue by inserting some extra URL parameters. 您可以通过插入一些额外的URL参数来测试这是客户端还是Wordpress问题。

Try hitting the page with ?extraRandomParameter=changeThisValueEachTime. 尝试使用?extraRandomParameter = changeThisValueEachTime访问页面。

If that works, it's a client thing; 如果可行,那是客户的事。 otherwise, you'll have to investigate more specifically as to how Wordpress caches (and how to get around it). 否则,您将不得不更具体地研究Wordpress缓存的方式(以及如何解决)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用更新的mysql数据库信息更新javascript中的php变量? - How do I update my php variables in javascript with updated mysql database information? 如何强迫学说读取新的映射信息 - How to force Doctrine to read new mapping information 如何强制 Excel 文件在浏览器中打开而不是下载 - How do I force Excel files to open in the browser instead of downloading 如何强制重新连接到 php 中的数据库? - How do I force reconnecting to my database in php? 如何使用PDO从数据库获取信息? - How do I get information from a database using PDO? 如何将购物车数据的 session 信息添加到数据库中? - How do i add information to a session of shopping cart data into a database? PHP-如何读取图片值并使其可被浏览器查看? - PHP - how do i read the picture value and make it viewable by browser? 如何在浏览器中强制下载图像? - How can I force an Image download in the browser? 如何使用表的ID从数据库中检索某些信息以提取某些信息? - How do I retrieve certain information from database using the ID of the table to extract certain information? 如何使用Ajax和Jquery从PHP数据库中提取信息,并使用该信息填充元素? - How do I use Ajax and Jquery to pull information off a PHP database, and populate elements with that information?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM