拍卖/ eBay风格计时器使用php和mysql?

时间:2013-03-26 20:57:34

标签: php mysql timer

我需要使用PHP / MySQL创建一个简单的计时器,类似于eBay计时器,但没有JavaScript。我知道eBay使用JavaScript来定时器开始滴答(没有页面刷新)。我不需要这一点。我只需要它显示“1”项目的剩余日期/分钟。

我在Google上搜索并找到了这段代码:

<?php



//list fields and convert to seconds

$countdown['days']=(1) * 24 * 60 * 60;

$countdown['hours']=(1) * 60 * 60;

// etc, etc

$countsum=time() + $countdown['days'] + $countdown['hours']; //and so on

// the above would be the timestamp to enter into the table



##########



// 'dumbed down' query
include "config/connect_to_mysql.php";

$result=mysql_query("SELECT * FROM tomProduct ORDER BY id DESC LIMIT 1;");



while ($row=mysql_fetch_assoc($result))

    $time=$row['date_added'] - time(); //this field would be a PHP timestamp (time())



$count=getdate($time);



$x=getdate(); //todays information



$count['mday'] -= $x['mday'];

$count['hour'] -= $x['mday'];

$count['minutes'] -= $x['minutes'];



echo "$count[mday] Days $count[hour] Hours $count[minutes] Minutes"; //etc



// untested, but should work

?>

我编辑并将其连接到我自己的MySQL数据库以查看它是如何工作的,并在页面上以这种格式显示时间:-19天-26小时-3分钟。

如果我每隔1分钟刷新一次页面,则分钟数将增加1.因此,基本上它不会倒计时;它真的很重要。

我需要这个来显示该特定产品剩下多少天/分钟,

如果用户刷新页面,那么如果需要,时间将会改变,就像在上面的脚本中一样。

目前,该项目的时间戳(发布时)被存储在MySQL数据库中作为“日期”和名为date_added的列。

有人能指出我正确的方向吗?

欢呼声

0 个答案:

没有答案
相关问题