Php Mysql\u查询如何将其用于“动态”数据库?

Php Mysql\u查询如何将其用于“动态”数据库?,php,jquery,mysql,database,Php,Jquery,Mysql,Database,今天我在我的网站上工作,试图展示游戏的最后赢家。这是我的密码: $lastgame = fetchinfo("value","info","name","current_game"); $winnercost = fetchinfo("cost","games","id",$lastgame-1); $winnerpercent = round(fetchinfo("percent","games","id",$lastgame-1),1); $winneravatar = fetchinf

今天我在我的网站上工作,试图展示游戏的最后赢家。这是我的密码:

 $lastgame = fetchinfo("value","info","name","current_game");

$winnercost = fetchinfo("cost","games","id",$lastgame-1);
$winnerpercent = round(fetchinfo("percent","games","id",$lastgame-1),1);
$winneravatar = fetchinfo("avatar","users","steamid",$lastwinner);
$winnername = fetchinfo("name","users","steamid",$lastwinner);



echo '<p>Game #'.$lastgame.'</p>'; 
echo '<p>'.$winnername.' won the jackpot</p>'; 
echo '<p> valued at '.$winnercost.'</p>'; 
echo '<p>with a winning chance of '.$winnerpercent.'</p>'; 
有人有办法帮我吗?这个-1

,$lastgame-1),1);
给了我一些困难:

atm网站上的结果:

第四场 狐狸赢了头奖 估值为3.31
根据您提供的信息,我认为您可以使用的最简单查询如下:

select * from <tblname> order by steamid desc limit 1;
对于自动刷新,您可以执行以下两种操作之一:

1) you could add: <meta http-equiv="refresh" content="5"> in the header of your html and the page will automatically refresh every 5 seconds.  (basic)

2) you could use ajax to make a call to execute the query and update the page which is a much nicer user experience (more advanced) 

使用php或任何其他首选服务器端编程web语言创建一个api页面,当调用该页面时,它可以提供最新的查询结果

然后在javascript中创建一个循环,每隔x秒向api页面发送一个ajax请求,并使用该数据,您可以使用jquery或js动态更新您的字段,这并不重要——您可能知道如何更新/更改文本

以下是一些资源:

ajax入门

更多ajax

从这里开始使用因为没有人提到它,让我指出PHP的mysql_查询函数与整个mysql API一起被弃用,并且将在下一版本的PHP中完全删除。您应该将代码切换为使用mysqli或PDO库。另外,如果您是一名PHP初学者,并且正在使用mysql_xxx函数,那么这可能意味着您一直在使用一些非常古老的教程来自学PHP;我强烈建议您尝试寻找一些更新的教程,因为自从mysql函数被弃用以来,PHP作为一种语言已经有了很大的发展
1) you could add: <meta http-equiv="refresh" content="5"> in the header of your html and the page will automatically refresh every 5 seconds.  (basic)

2) you could use ajax to make a call to execute the query and update the page which is a much nicer user experience (more advanced)