ich habe hier ein script, das meine Zählerdaten jeweils am Ende des Intervalls auf 1 zurücksetzen soll. Es funktioniert aber nicht. Die Daten werden zu Ende eines Intervals (nach einer Minute) nicht auf 1 gesetzt. Was mache ich falsch?
Hier das Script:
include '../kommenundwohlfuehlen/db/mysql.inc.php';
include '../kommenundwohlfuehlen/db/connect.php';
$sql = "UPDATE
count_hotel
SET
number_hotel = number_hotel + 1
WHERE
id = 1;";
mysql_query($sql) OR die(mysql_error());
$sql = "SELECT
DATE_FORMAT(datum,'".DATE_STYLE."') as start,
DATE_FORMAT(DATE_ADD(datum, INTERVAL 1 Minute),'".DATE_STYLE."') as stop,
NOW() BETWEEN
datum AND
DATE_ADD(datum, INTERVAL 1 Minute) as laeuft
FROM
count_hotel
LIMIT
1;";
$result = mysql_query($sql) OR die (mysql_error());
$row= mysql_result($result,0);
if(isset($row['stop']))
{
$sql = "UPDATE
count_hotel
SET
number_hotel = '1'
WHERE
id = 1;";
mysql_query($sql) OR die (mysql_error());
echo $row['start'];
}
$sql = "SELECT
number_hotel
FROM
count_hotel
WHERE
id = 1;";
$result = mysql_query($sql) OR die (mysql_error());
$number_hotel = mysql_result($result,0);
echo $number_hotel;
?>
Hier das Script:
include '../kommenundwohlfuehlen/db/mysql.inc.php';
include '../kommenundwohlfuehlen/db/connect.php';
$sql = "UPDATE
count_hotel
SET
number_hotel = number_hotel + 1
WHERE
id = 1;";
mysql_query($sql) OR die(mysql_error());
$sql = "SELECT
DATE_FORMAT(datum,'".DATE_STYLE."') as start,
DATE_FORMAT(DATE_ADD(datum, INTERVAL 1 Minute),'".DATE_STYLE."') as stop,
NOW() BETWEEN
datum AND
DATE_ADD(datum, INTERVAL 1 Minute) as laeuft
FROM
count_hotel
LIMIT
1;";
$result = mysql_query($sql) OR die (mysql_error());
$row= mysql_result($result,0);
if(isset($row['stop']))
{
$sql = "UPDATE
count_hotel
SET
number_hotel = '1'
WHERE
id = 1;";
mysql_query($sql) OR die (mysql_error());
echo $row['start'];
}
$sql = "SELECT
number_hotel
FROM
count_hotel
WHERE
id = 1;";
$result = mysql_query($sql) OR die (mysql_error());
$number_hotel = mysql_result($result,0);
echo $number_hotel;
?>
Kommentar