Jump to content

Mysql query to fetch & compare


tourer

Recommended Posts

hi friends. i am working on a php which would be added up to the scheduled tasks. This php will compare the Current server time & the endtime fetched from the database. Suppose endtime field consists of 8 values & anyone value is equal to the currnt time, then the php page will execute a script.

 

Here is my humble try so far. But i am able to fetch value, but when i echo the results, the result for all the condition is displayed:_

 

endtime.php:-

<?php

date_default_timezone_set('Asia/Kolkata');

$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'XXXX';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die   ('Error connecting to mysql');

$dbname = 'fsdfsd';

mysql_select_db($dbname,$conn) or die ("could not open db".mysql_error());

//$Tdate = date('H') * 60 + date('i');
//$site = "http://118.102.191.40/experiments/e1.html";
$Tdate = 720;
   $sql = "SELECT endtime
          FROM reservations";
             
   $result = mysql_query($sql)
            or die('Query failed. ' . mysql_error());

//Fetch Data and use $row to get fields data		 
While ($row = mysql_fetch_array($result)) { 

//echo "End Time: ".$row['endtime'];
//}
if ($Tdate == $row["endtime"]) {
echo "Yeah, Gud Going";
//exit($site); 

} else {

echo "Work Hard"; 
}
}
?>

 

the Result it displays:-

Work HardWork HardYeah, Gud GoingWork HardWork HardWork Hard

 

This shows that 720 is my 3rd entry from the bottom. Although i want the php to fetch all the table endtime Value's, Compare them with current server time, if any value matches, then a specified html page needs to be exited.

 

Also can some one lead me through this exit stuff. Now this html page is running a swf file. The user books a slot to use this swf file. He mentions a starttime & endtime. Now the entering mechanism i have installed n started up. This endtime php will check the end time & force the html to exit. so is it possible to run some php scheduled for every 5 min, to end a html webpage at any remote PC. Cuz it is running through my Webserver. Can i abort that page whenever i want.....

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.