PHP "live" hours

I am extremely new to PHP, however I think I can manage with a little help. I’ll give you a little information about my situation. I am a student working for Eastern Michigan University as their web admin. They would like for me to implement i guess you would call it a “live” building hours schedule where it shows what vendors are open in the student center when ever some one comes to the website. The problem I am having is that it is bonded by so many conditions, for instance that all of the vendors are closed on the weekend, but during the week they all open and close at different hours. Do I have to right a separate PHP script for each instance or can i create a complex if and else statement that will do this. Basically I would like it to just display Open or Closed. I guess I’m just lacking direction on how to start it. Does anyone know any tutorials that deal with something like this, instead of the basic “hello world” tutorials? Also how would I implement this into the actual website?

Any help would be awesome.

Chad

Sounds like the best thing to do is store them in a database.

Perhaps VENDOR, OPEN-TIME, CLOSE-TIME (and some unique ID).

Then at every visit to the site, you query the database TIME and if the CURRENT time is greater than OPEN-TIME but less than CLOSE-TIME, display OPEN otherwise display CLOSE.

Perhaps something like:

<? 
$currentTime = time();
$link = mysql_connect(Details, Details, Details);
$sql = "SELECT * FROM vendorlist";
$result = mysql_db_query("dbName", $sql);
while ($data = mysql_fetch_assoc($data)) {
   if ($currentTime >= $data['open-time'] &&  $currentTime <= $data['close-time'] ) {
      echo $data['vendor']." - <b>OPEN</b>";
   } else {
      echo $data['vendor']." - <b>CLOSED</b>";
   }
  echo "<br>";
}
Sponsor our Newsletter | Privacy Policy | Terms of Service