Jump to content

Date and time problem


feichter

Recommended Posts

Perhaps someone can help me please. This is driving me crazy!

I have copied and adapted a script that displays a table with dates and times.

The script generates the dates 5 working days ahead and times from 7.00 till 16.00.

Every cell shows an "A".

When clicking a date, the script connects to the db and adds the date and time to the db.

I now need to show the dates and times that are in the db with a "B" for "booked".

The db has the following columns: id, deldate, deltime.

 

See script below:

 

<?php

$font_size = 1;

$how_many_business_days_ahead = 1;

$how_many_business_days_to_count = 10;

$numdel = 10; // number of deliveries per day

$deltimestart = 7; //start delivery time

$int = 1; // hourly interval between deliveries

 

$numdel = $numdel - 1;

$time = $deltimestart - $int;

 

/////////////////////////////

 

$server= "your_server";

$user= "user";

$password= "password";

$database= "database";

$table= "delivery";

 

MYSQL_CONNECT($server, $user, $password) or die ( "<H3>Server unreachable</H3>");

MYSQL_SELECT_DB($database) or die ( "<H3>Database non existent</H3>");

 

if ($date != "" && $time != "") { // This enters the data into the db

$req_date = $_REQUEST['date'];

$req_time = $_REQUEST['time'];

 

$insertion = "INSERT INTO $table VALUES ('','$req_date','$req_time')";

$result_insertion = mysql_query($insertion) or die ("Updating failed");

}

 

for ($c=0;$c<$how_many_business_days_to_count;$c++)

{

$jump=$c+$how_many_business_days_ahead;

$theday = strftime("%A", strtotime("+$jump"));

if($theday != "Saturday" and $theday != "Sunday")

{

$days = $how_many_business_days_ahead+$c;

$the_days[$j] = strftime("%Y-%m-%d", strtotime("+$jump days"));

$j++;

}

}

$k = $how_many_business_days_ahead;

 

echo "<table border=\"1\">";

echo "<tr><td></td>";

 

for ($a=0;$a<10;$a++){

$deltimefinish = $deltimestart;

$deltimestart = $deltimestart + $int;

echo "<td width=\"50\" align=\"center\"><font size=\"$font_size;\">$deltimefinish - $deltimestart</font></td>";

}

 

echo "</tr>";

 

foreach($the_days as $eachday){

echo "<tr><td><font size=\"$font_size\">";

echo strftime("%a, %d %b", strtotime("$eachday"));

echo "</font></td>";

$k++;

 

for ($i=0;$i<=$numdel;$i++){

 

if ($time>"15"){

$time = "7";

echo "<td align=\"center\"><font size=\"$font_size\"><a href=\"deliverydates.php?date=$eachday&time=$time\">A</a></font></td>";

} else {

$time = $time + 1;

echo "<td align=\"center\"><font size=\"$font_size\"><a href=\"deliverydates.php?date=$eachday&time=$time\">A</a></font></td>";

}

}

}

echo "</tr>";

echo "</table>";

 

/* Close SQL-connection */

MYSQL_CLOSE();

?>

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.