今天我在我的网站上工作,试图显示游戏的最后一个赢家。这是我的代码:
$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场比赛 Foxy赢得了大奖 价值3.31 获胜机会为94.6
答案 0 :(得分:2)
根据您提供的信息,我认为您可以使用的最简单的查询类似于:
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)
答案 1 :(得分:0)