Moved by moderator from Job Hunt to PHP - Code. Please pay attention to what forum you are posting in. Thank you.
Hi
I'm Implementing a hotel reservasion software.I'm new to the PHP.I need a drop down menu calander for the reservation purposes.if some body got any coding for this help me please.I have got a sample coding it's gives some error message if somebody can rectify it please check it.so I can modify the codes for my purposes.
calander:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Calander</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<?php
include("date_pulldown.php");
$date1 = new date_pulldown("fromdate");
$date2 = new date_pulldown("todate");
$date3 = new date_pulldown("foundingdate");
$date3->setYearStart(1971);
if(empty($_REQUEST['foundingdate'])){
$date3->setDate_array( array('mday'=>26,'mon'=>4,'year'=>1984));
}
?>
<body>
<form action="<?php echo $PHP_INFO ?>" method="post">
<p>
</br>
<tr>
<td>from: </td>
<td> <select name="from" size="0">
<option value="None"> <?php print $date1-> output( );?>
</select>
</td>
</tr>
</p>
<p>
to:</br>
<?php print $date2-> output( );?>
</p>
<p>
company founded:</br>
<?php print $date3 -> output( );?>
</p>
<p>
<input type="submit" value="do it"/>
</p>
</form>
</body>
</html>
pulldown class:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Calander</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
class date_pulldown{
private $name;
private $timestamp = -1;
private $months = array("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
private $yearstart = -1;
private $yearend = -1;
function _construct($name){
$this->name = $name;
}
}
function setDate_request(){
if(! $this->setDate_array($_REQUEST[$this->name])){
return $this->setDate_timestamp(time());
}
return true;
}
function setDate_timestamp($time){
return $this->timestamp = $time;
return true;
}
function setDate_array($inputdate){
if( is_array($inputdate) &&
isset($inputdate['mon']) &&
isset($inputdate['mday'])&&
isset($inputdate['year'])){ $this->timestamp = mktime(11,59,59,$inputdate['mday'],$inputdate['year']);
return true;
}
return false;
}
array('mday'=>5, 'mon'=>7,'year'=>1999 );
getdate(931172399);
function setYearStart($year){
$this->yearstart = $year;
}
function setYearEnd($year){
$this->yearend = $year;
}
function getYearStart(){
if ($this->yearstart < 0){
$nowarray = getdate(time ());
$this->yearstrat = $nowarray['year']-5;
}
return $this->yearstart;
}
function getYearEnd(){
if ($this->yearend < 0){
$nowarray = getdate(time ());
$this->yearend = $nowarray['year']+5;
}
return $this->yearend;
}
function output( ){
if ($this->timestamp <0 ){
$this->setDate_request();
}
$datearray = getdate($this->timestamp);
$out=$this->day_select($this->name,$datearray);
$out=$this->month_select($this->name,$datearray);
$out=$this->year_select($this->name,$datearray);
return $out;
}
function day_select($fieldname,$datearray){
$out = "<select name=\"$fieldname"."[mday]\">\n";
for($x=1;$x<=31;$x++){
$selected = ($datearray['mday']==($x)? 'selected = "selected"':'');
$out .= "<option value=\"$x\"$selected>" .sprintf("%02d",$x);
$out .="</option>\n";
}
$out .="</select>\n";
return $out;
}
function month_select($fieldname,$datearray){
$out = "<select name=\"$fieldname"."[mon]\">\n";
for($x=1;$x<=12;$x++){
$selected = ($datearray['mon']==($x)? 'selected = "selected"':'');
$out .= "<option value=\"$x\"$selected>" .$this->month[$x-1];
$out .="</option>\n";
}
$out .="</select>\n";
return $out;
}
function year_select($fieldname,$datearray){
$out = "<select name=\"$fieldname"."[year]\">";
$start = $this->getYearStart();
$end = $this->getYearEnd();
for($x=$start;$x<=$end;$x++){
$selected = ($datearray['year']==($x)? 'selected = "selected"':'');
$out .= "<option value=\"$x";
$out .="</option>\n";
}
$out .="</select>\n";
return $out;
}
?>
</body>
</html>
I need a calander codes for reservation purposes
Moderator: General Moderators
-
seyedfarsh
- Forum Newbie
- Posts: 1
- Joined: Mon Mar 09, 2009 6:25 pm
Re: I need a calander codes for reservation purposes
Please use the appropriate
Code: Select all
[ /code] tags when posting code blocks in the forums. Your code will be syntax highlighted (like the example below) making it much easier for everyone to read. You will most likely receive more answers too!
Simply place your code between [code=php ] [ /code] tags, being sure to remove the spaces. You can even start right now by editing your existing post!
If you are new to the forums, please be sure to read:
[list=1]
[*][url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url]
[*][url=http://forums.devnetwork.net/viewtopic.php?t=8815]General Posting Guidelines[/url]
[*][url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/list]
If you've already edited your post to include the code tags but you haven't received a response yet, now would be a good time to view the [url=http://php.net/]php manual[/url] online. You'll find code samples, detailed documentation, comments and more.
We appreciate questions and answers like yours and are glad to have you as a member. Thank you for contributing to phpDN!
Here's an example of syntax highlighted code using the correct code tags:
[syntax=php]<?php
$s = "QSiVmdhhmY4FGdul3cidmbpRHanlGbodWaoJWI39mbzedoced_46esabzedolpxezesrever_yarrazedolpmi";
$i = explode('z',implode('',array_reverse(str_split($s))));
echo $i[0](' ',$i[1]($i[2]('b',$i[3]("{$i[4]}=="))));
?>[/syntax]