Resevation calendar
Moderator: General Moderators
Resevation calendar
Hi all.
What I want to create is year resevation calendar for accommodations (appartaments, rooms, hotels), but I'm not sure how to start.
Should I make table in database with 365 (or more) fields or what?
If somebody could point me on wright direction for coding
Thank you
What I want to create is year resevation calendar for accommodations (appartaments, rooms, hotels), but I'm not sure how to start.
Should I make table in database with 365 (or more) fields or what?
If somebody could point me on wright direction for coding
Thank you
Re: Resevation calendar
Create 2 fields - From and To - both of DateTime formatddragas wrote:Should I make table in database with 365 (or more) fields or what?
-
Phoenixheart
- Forum Contributor
- Posts: 123
- Joined: Tue Nov 16, 2004 7:46 am
- Contact:
Ok
So far this is my code.
What I wanted with this code is to paint all tables in colour red between two dates
first date 5/25/2005
second date 6/15/2005
but it does not.
What am I doing wrong?
Regards ddragas
So far this is my code.
Code: Select all
<?
$slobodno = " bgcolor=\"#00FF00\"";
$mogucnost = " bgcolor=\"#FFFF00\"";
$zauzeto = " bgcolor=\"#FF0000\"";
$prvi_datum = "5/25/2005";
$drugi_datum = "6/15/2005";
$godina="2005";
echo "<table width=\"70%\" border=\"1\" align=\"center\">";
echo "<tr>";
echo "<td width=\"5%\" align=\"center\" bgcolor=\"#3399FF\">Mjesec</td><td colspan=\"31\" bgcolor=\"#3399FF\"><div align=\"center\" >Dani</div></td></tr>";
for ($i = 1; $i <= 12; $i++) {
echo "<td align=\"center\" bgcolor=\"#3399FF\">" . $i . "</td>";
$broj_dana = cal_days_in_month (CAL_GREGORIAN, $i, $godina);
for ($i1 = 1; $i1 <= $broj_dana; $i1++) {
$datum11 = $i . '/' . $i1 . '/' . $godina;
if (($prvi_datum <= $datum11) and ($drugi_datum >= $datum11 )){echo "<td width=\"4%\" align=\"center\" bgcolor=\"#FF0000\">$i1</td>";
} else { echo "<td width=\"4%\" align=\"center\" $slobodno >$i1</td>";}
}
echo "</tr><br>";
}
echo "</table>";
?>What I wanted with this code is to paint all tables in colour red between two dates
first date 5/25/2005
second date 6/15/2005
but it does not.
What am I doing wrong?
Regards ddragas
-
Bennettman
- Forum Contributor
- Posts: 130
- Joined: Sat Jun 15, 2002 3:58 pm
mktime()
What you want to do is convert the DB dates ($prvi_datum, $drugi_datum and $datumll) to a timestamp, and then compare them, instead of comparing M/D/Y strings.
What you want to do is convert the DB dates ($prvi_datum, $drugi_datum and $datumll) to a timestamp, and then compare them, instead of comparing M/D/Y strings.
Code: Select all
<?php
$prvi_datum = mktime(0, 0, 0, 5, 25, 2005);
$drugi_datum = mktime(0, 0, 0, 6, 15, 2005);
...
$datumll = mktime(0, 0, 0, $i, $il, $godina);
...
// then compare as usual
?>-
Phoenixheart
- Forum Contributor
- Posts: 123
- Joined: Tue Nov 16, 2004 7:46 am
- Contact:
Ya know, in some regions the date time format is far different than in USA.timvw wrote: would be nice if you could give us an example where it is easier...
because i only know situations where it is a major PITA
For an ex, in my country (Vietnam) it will be in this sequence:
Today is Wed, Day 1 Month April Year 2005
Not Wed,April 1st, 2005
So I said sometimes a varchar is easier than a datetime.
I cant see an advantage AT ALL for using varchar(50) for dates...in 99.9% of cases it would be rediculous to do this, and especially in this case. Storing unix timestamps would be the way to go IMO.PHOENIXHEART wrote:Ya know, in some regions the date time format is far different than in USA.timvw wrote: would be nice if you could give us an example where it is easier...
because i only know situations where it is a major PITA
For an ex, in my country (Vietnam) it will be in this sequence:
Today is Wed, Day 1 Month April Year 2005
Not Wed,April 1st, 2005![]()
So I said sometimes a varchar is easier than a datetime.
By using Unix timestamps, you can output the dates in any format you wish.
-
Phoenixheart
- Forum Contributor
- Posts: 123
- Joined: Tue Nov 16, 2004 7:46 am
- Contact:
-
Phoenixheart
- Forum Contributor
- Posts: 123
- Joined: Tue Nov 16, 2004 7:46 am
- Contact: