Jump to content


This topic is now archived and is closed to further replies.


Date and time problem

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:



$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++)



$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"));




$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>";



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 */



Share this post

Link to post
Share on other sites


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.