今天我在我的网站上工作,试图显示游戏的最后获胜者。这是我的代码:
$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>';
关键是我只使用 fetchinfo,所以它显示信息但不是实时的,我必须刷新我的页面才能显示最新的获胜者。我想我需要创建一个 mysql_query。
我的问题是我不明白如何使用 mysql_query,我知道每次获胜者获胜都会在我的表中创建一个新行。例如:
id : 1
startime :1441330544
total price : 3.17
Winner : Foxy
steam id : 76561198042016725
Percent chances to win : 98.7381703
Number of total item : 2
module : 0.24973750
谁有解决方案可以帮助我?这个-1
,$lastgame-1),1);
给我一些困难:(
网站atm上的结果:
游戏#4 狐狸中了大奖 值(value)3.31 获胜几率为 94.6
最佳答案
根据您提供的信息,我认为您可以使用的最简单的查询如下:
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 - mysql_query如何与一个 "dynamic"数据库一起使用呢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32398641/