Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Need help with php script connecting to jscalendar
Old 01-27-2010, 09:26 PM Need help with php script connecting to jscalendar
Novice Talker

Posts: 6
Name: Diane B
Trades: 0
Hi,
I am new and need some help with a php script that is embedded in an html page, and calls data from a mysql db.

it provides details and pics and calendar feature using jscalendar. Can't get the calendar to appear.
Note: this had been working. we moved hosts and can't get it work now. did change paths in script, but still not working. Can someone look at this code and see anything wrong? I'm losing my sanity at this point :-)


PHP Code:
<?php
global $chalet;
global 
$yestext;
global 
$notext;
global 
$imagepath;
global 
$bedrmrange;
 
$chalet $_GET["chalet"];
$imagepath "/html/images/chalets/cabin" $chalet "_0.jpg";
$i 0;
while (
file_exists("/htmlimages/chalets/cabin" $chalet "_" $i ".jpg")) {
$i++;
}
function 
QueryIntoArray($query){
settype($retval,"array");
$resultmysql_query($query);
if(!
$result){
print 
"Query Failed";
for(
$i=0;$i<mysql_numrows($result);$i++) {
for(
$j=0;$j<mysql_num_fields($result);$j++) {
$retval[$i][mysql_field_name($result,$j)] = mysql_result($result,$i,mysql_field_name($result,$j));
}
//end inner loop
}//end outer loop
}
return 
$retval;
}
//end function 
?> 
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Chalet Details</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script Language="JavaScript">
<!--
// PicPager -- Show a series of images in one position on the page.
// Call from body tag: <body onLoad="PicPager()">
// User configuration variables. Set the following for your application.
//-------------------------------------------------------------------------------//
var interval = 4.0 // How long to show each picture in seconds.
// Range from about 0.1 or less to whatever.
var num_pics = <?php print("$i"); ?> // How many pictures to cycle through.
// As many as you want to load.
var pic_name = "http://www.webmaster-talk.com/images/chalets/cabin<?php print("$chalet"_"); ?>" // Base name of picture files. Example filenames:
// "picture0.gif", "picture1.gif", etc.
var file_ext = ".jpg" // File extension of picture files.
var img_index = 0 // Which image to replace. The first image specified
// in the html code is document.images[0].
//-------------------------------------------------------------------------------//
// Do not change this value.
var pic_count = -1
// Load all the images.
Picture=new Array(num_pics)
for (var i=0; i < num_pics; i++) {
Picture[i]=new Image()
Picture[i].src=pic_name + i + file_ext
}
var timerID = null
function PicPager() {
pic_count += 1
if (pic_count == num_pics)
pic_count = 0
document.images[img_index].src = pic_name + pic_count + file_ext
timerID=setTimeout("PicPager()", interval * 1000)
}
// -->
</script>
<link rel="stylesheet" type="text/css" media="all" href="jscalendar/chalet.css" title="" />
<!-- main calendar program -->
<script type="text/javascript" src="jscalendar/calendar.js"></script>
<!-- language for the calendar -->
<script type="text/javascript" src="jscalendar/lang/calendar-en.js"></script>
<!-- the following script defines the Calendar.setup helper function, which makes
adding a calendar a matter of 1 or 2 lines of code. -->
<script type="text/javascript" src="jscalendar/calendar-setup.js"></script>
<style type="text/css">
.past { background-color: #666666; color: #fff; }
.booked { background-color: #CC0000; color: #fff; }
.pending { background-color: #FFCC00; color: #fff; } 
.open { background-color: #00CC00; color: #fff; }
</style>
</head>
<body onLoad="window.focus(); PicPager()" bgcolor="#9999CC" link="#FFFF00" vlink="#FFFF00" alink="#FFFFFF" leftmargin="0" topmargin="5" marginwidth="0" marginheight="5">
<table>
<tr>
<td valign="top">
<table width="600" height="450" border="0" align="center" cellpadding="5" cellspacing="0">
<tr>
<?php
$firstDayOfMonth 
strftime("%Y-%m-%d",mktime(000date("m"), 1date("Y")));
$yestext "<b><font color='#FFFF00' size='2' face='Verdana, Arial, Helvetica, sans-serif'>YES</font></b>";
$notext "<font size='2' face='Verdana, Arial, Helvetica, sans-serif'>No</font>";
 
$query "SELECT * FROM ChaletList WHERE ChaletNo = $chalet";
 
$db mysql_connect("pmccdb.db.4837414.hostedresource.com","pmccdb""Pcpart1");
 
if ( !
$db //Bad connection screen
{
echo 
"<td><center><font face='Arial, Helvetica, sans-serif' color='#990000'><b>An error occurred while attempting to connect to the database.</b></font></center></td></tr></table></body></html>";
exit;
}
$result mysql_select_db("pmccdb"); 
if (!
$result) {
echo 
"<td><center><font face='Arial, Helvetica, sans-serif' color='#990000'><b>An error occurred while attempting to select the database.</b></font></center></td></tr></table></body></html>";
exit;
}
$result mysql_query($query);
if (!
$result) {
echo 
"<td><center><font face='Arial, Helvetica, sans-serif' color='#990000'><b>An error occurred while attempting to query the database: $query </b></font></center></td></tr></table></body></html>";
exit;
}
$rowcount mysql_num_rows($result); 
$ra mysql_fetch_array($result); 
mysql_free_result($result);
$dates QueryIntoArray("SELECT booked_date, status FROM Reservations WHERE chalet_id=$chalet AND booked_date>='$firstDayOfMonth';");
 
$pending_dates = array();
$booked_dates = array();
 
for(
$i=0;$i<count($dates);$i++) {
$date strtotime($dates[$i]['booked_date']);
$month = (int) strftime('%m',$date);
$year = (int) strftime('%Y',$date);
if (
$dates[$i]['status']==0) {
$pending_dates[($year*100)+$month-1].= ", "strftime('%e',$date);
} else {
$booked_dates[($year*100)+$month-1].= ", "strftime('%e',$date);
}
}
mysql_close($db);
 
if ( 
$chalet == 16 //Service Lot
{
echo 
"<td><center><font face='Arial, Helvetica, sans-serif'><b>Services Only</b></font></center></td></tr></table></body></html>";
exit;
}
 
if ( (
$rowcount == 0) || ($ra[ForRent] != "Y") ) //No record screen
{
echo 
"<td><center><font face='Arial, Helvetica, sans-serif'><b>Chalet No. $chalet is currently not in the Rental Program.</b></font></center></td></tr></table></body></html>";
exit;
}
 
if (
$ra[OnLake] == "X"){$ra[OnLake] = "<font color='#FFFF00' size='2'>-Lakefront-</font>";}
else{
$ra[OnLake] = "";}
if (
$ra[Lakeview] == "X"){$ra[Lakeview] = "<font color='#FFFF00' size='2'>-Lakeview-</font>";}
else{
$ra[Lakeview] = "";}
if (
$ra[MeadowView] == "X"){$ra[MeadowView] = "<font color='#FFFF00' size='2'>-Meadow View-</font>";}
else{
$ra[MeadowView] = "";}
if (
$ra[NearRecreation] == "X"){$ra[NearRecreation] = "<font color='#FFFF00' size='2'>-Near Recreation-</font>";}
else{
$ra[NearRecreation] = "";}
if (
$ra[OffLake] == "X"){$ra[OffLake] = "<font color='#FFFF00' size='2'>-Off Lake-</font>";}
else{
$ra[OffLake] = "";}
if (
$ra[Culdesac] == "X"){$ra[Culdesac] = "<font color='#FFFF00' size='2'>-Cul-de-sac-</font>";}
else{
$ra[Culdesac] = "";}
if (
$ra[NearAlpinecenter] == "X"){$ra[NearAlpinecenter] = "<font color='#FFFF00' size='2'>-Near Alpine Center-</font>";}
else{
$ra[NearConfcenter] = "";}
if (
$ra[nearrestaurant] == "X"){$ra[nearrestaurant] = "<font color='#FFFF00' size='2'>-Near Restaurant-</font>";}
else{
$ra[nearrestaurant] = "";}
if (
$ra[Fireplace] == "X"){$ra[Fireplace] = $yestext;}
else{
$ra[Fireplace] = $notext;}
if (
$ra[VCR] == "X"){$ra[VCR] = $yestext;}
else{
$ra[VCR] = $notext;} 
if (
$ra[DVD] == "X"){$ra[DVD] = $yestext;}
else{
$ra[DVD] = $notext;}
if (
$ra[Dishwasher] == "X"){$ra[Dishwasher] = $yestext;}
else{
$ra[Dishwasher] = $notext;}
if (
$ra[NonSmoking] == "X"){$ra[NonSmoking] = $yestext;}
else{
$ra[NonSmoking] = $notext;}
if (
$ra[WasherDryer] == "X"){$ra[WasherDryer] = $yestext;}
else{
$ra[WasherDryer] = $notext;}
if (
$ra[Phone] == "X"){$ra[Phone] = $yestext;}
else{
$ra[Phone] = $notext;}
if (
$ra[HeatAir] == "X"){$ra[HeatAir] = $yestext;}
else{
$ra[HeatAir] = $notext;}
if (
$ra[Ramp] == "X"){$ra[Ramp] = $yestext;}
else{
$ra[Ramp] = $notext;}
if (
$ra[Porch] == "X"){$ra[CableTV] = $yestext;}
else{
$ra[Porch] = $notext;}
if (
$ra[MeetingRm] == "X"){$ra[MeetingRm] = $yestext;}
else{
$ra[MeetingRm] = $notext;}
if (
$ra[Porch] == "X"){$ra[Porch] = $yestext;}
else{
$ra[Porch] = $notext;}
if (
$ra[TBeds] == 0){$ra[TBeds] = "-";}
if (
$ra[DBeds] == 0){$ra[DBeds] = "-";}
if (
$ra[QBeds] == 0){$ra[QBeds] = "-";}
if (
$ra[KBeds] == 0){$ra[KBeds] = "-";}
 
if (
$ra[MinBRUnits] == $ra[MaxBRUnits]){$bedrmrange $ra[MinBRUnits];}
else{
$bedrmrange "$ra[MinBRUnits] - $ra[MaxBRUnits]";}
 
if(
substr($ra[Baths],2,1) == 0){$ra[Baths] = substr($ra[Baths],0,1);}
 
//image stuff here
 
 
if (!file_exists("$imagepath")){$imagepath "http://www.webmaster-talk.com/images/chalets/pna.jpg";} 
 
echo <<<CHALETDETAILS
<td width="400" height="300" align="center"><img src="$imagepath"></td>
<td rowspan="2" align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr align="center"> 
<td colspan="2"><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Number of Beds</font></b></td>
</tr>
<tr> 
<td width="50%"><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Twin:</font></b></td>
<td><b><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">
$ra[TBeds]</font></b></td>
</tr>
<tr> 
<td><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Double:</font></b></td>
<td><b><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">
$ra[DBeds]</font></b></td>
</tr>
<tr> 
<td><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Queen:</font></b></td>
<td><b><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">
$ra[QBeds]</font></b></td>
</tr>
<tr> 
<td><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif">King:</font></b></td>
<td><b><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">
$ra[KBeds]</font></b></td>
</tr>
</table>
<br>
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr> 
<td colspan="2" align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Amenities</b></font></td>
</tr>
<tr> 
<td width="70%"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Fireplace:</b></font></td>
<td>
$ra[Fireplace]</td>
</tr>
<tr> 
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>VCR:</b></font></td>
<td>
$ra[VCR]</td>
</tr>
<tr>
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>DVD:</b></font></td>
<td>
$ra[DVD]</td>
</tr>
<tr> 
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Dishwasher:</b></font></td>
<td>
$ra[Dishwasher]</td>
</tr>
<tr> 
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Washer/Dryer:</b></font></td>
<td>
$ra[WasherDryer]</td>
</tr>
<tr> 
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Ramp:</b></font></td>
<td>
$ra[Ramp]</td>
</tr>
<tr> 
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Non-smoking:</b></font></td>
<td>
$ra[NonSmoking]</td>
</tr>
<tr> 
</tr>
<tr> 
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Meeting Room(Add'l Charge):</b></font></td>
<td>
$ra[MeetingRm]</td>
</tr>
<tr> 
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Screened Porch:</b></font></td>
<td>
$ra[Porch]</td>
</tr>
 
</table>
</td>
</tr>
<tr> 
<td align="center" valign="top">
<p><b><font color="#FFFFFF" size="3" face="Verdana, Arial, Helvetica, sans-serif">CHALET No. 
$chalet<br>
<table border="0" cellspacing="0" cellpadding="2" align="center">
<tr> 
<td colspan="2" align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Refer to Rates page for Rate Information and Specials.</b></font></td>
</tr>
</table>
$ra[OnLake]
$ra[Lakeview]
$ra[MeadowView]
$ra[NearRecreation]
$ra[OffLake]
$ra[Culdesac]
$ra[NearAlpinecenter]
$ra[nearrestaurant]
<br>
<b><font size="2" face="Verdana, Arial, Helvetica, sans-serif">*Can Be Rented as 
$bedrmrange Bedrooms, $ra[Baths] Bathrooms</font><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> Seasonal Restrictions May Apply.</b></p>
CHALETDETAILS;
?>
</td>
</tr>
</table>
</td>
<td valign="top">
<div style="width: 200px;float: left;">
<div style="padding: 8px 0 10px 0;" align="center"><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Availability</font></b></div>
<div style="float: left;" id="calendar-container"></div>
<br style="clear: both;">
<table cellspacing="8" cellpadding="0" border="0">
<tr>
<td><div class="open" style="float: left; width: 20px; height: 20px;"></div></td>
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Available</b></font></td>
</tr>
<tr>
<td><div class="pending" style="float: left; width: 20px; height: 20px;"></div></td>
<td>
<font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Owner/Maint. Block</b></font><br>
<font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b></b></font>
</td>
</tr>
<tr>
<td><div class="booked" style="float: left; width: 20px; height: 20px;"></div></td>
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Reserved</b></font><br></td>
</tr> 
</table>
</div>
<script type="text/javascript">
function dateChanged(calendar) {
// Beware that this function is called even if the end-user only
// changed the month/year. In order to determine if a date was
// clicked you can use the dateClicked property of the calendar:
if (calendar.dateClicked) {
// OK, a date was clicked, redirect to /yyyy/mm/dd/index.php
var y = calendar.date.getFullYear();
var m = calendar.date.getMonth(); // integer, 0..11
var d = calendar.date.getDate(); // integer, 1..31
// redirect...
// window.location = "/" + y + "/" + m + "/" + d + "/index.php";
}
};
 
<?php
echo "var PENDING_DAYS = {\n";
foreach (
$pending_dates as $month => $days) {
echo 
"$month : [" trim($days",") . " ], \n"
}
echo 
"99 : [ ]\n";
echo 
" };\n\n\n";
echo 
"var BOOKED_DAYS = {\n";
foreach (
$booked_dates as $month => $days) {
echo 
"$month : [" trim($days",") . " ], \n"
}
echo 
"99 : [ ]\n";
echo 
" };\n";
?>
function dateIsBooked(year, month, day) {
var m = BOOKED_DAYS[(year*100)+month];
if (!m) return false;
 
for (var i in m) if (m[i] == day) return true;
return false;
};
 
function dateIsPending(year, month, day) {
var m = PENDING_DAYS[(year*100)+month];
if (!m) return false;
 
for (var i in m) if (m[i] == day) return true;
return false;
}; 
function ourDateStatusFunc(date, y, m, d) {
if (dateIsBooked(y, m, d))
return "booked";
else if (dateIsPending(y, m, d))
return "pending"
else
return "open"; // other dates are enabled
// return true if you want to disable other dates
};
 
Calendar.setup(
{
flat : "calendar-container", // ID of the parent element
// flatCallback : dateChanged, // our callback function
weekNumbers : false,
dateStatusFunc : ourDateStatusFunc
}
 
</script></td>
</tr>
</table>
</body>
</html>

Last edited by chrishirst; 01-28-2010 at 08:33 AM.. Reason: added code tags
deedles2740 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-27-2010, 10:28 PM Re: Need help with php script connecting to jscalendar
Novice Talker

Posts: 6
Name: Diane B
Trades: 0
Anyone? Really need help here
deedles2740 is offline
Reply With Quote
View Public Profile
 
Old 01-28-2010, 08:36 AM Re: Need help with php script connecting to jscalendar
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Need a URI.

Quote:
embedded in an html page
And is the server set to parse PHP in .html pages?
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-28-2010, 07:49 PM Re: Need help with php script connecting to jscalendar
Novice Talker

Posts: 6
Name: Diane B
Trades: 0
url is www pinemountainclubchalets.com/bookonline.php

called web host to verify and yes they say i should be avle to parse php thru html

Last edited by chrishirst; 01-31-2010 at 11:16 AM.. Reason: URL edited to page with the problem
deedles2740 is offline
Reply With Quote
View Public Profile
 
Old 01-28-2010, 07:49 PM Re: Need help with php script connecting to jscalendar
Novice Talker

Posts: 6
Name: Diane B
Trades: 0
i am wondering if its something in teh jscalendar files??
deedles2740 is offline
Reply With Quote
View Public Profile
 
Old 01-30-2010, 05:55 PM Re: Need help with php script connecting to jscalendar
Novice Talker

Posts: 6
Name: Diane B
Trades: 0
Any help? If no one is interested...should I just remove the post or what?
deedles2740 is offline
Reply With Quote
View Public Profile
 
Old 01-30-2010, 06:31 PM Re: Need help with php script connecting to jscalendar
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Works for me in FF & IE assuming it is the "availability" page you are having problems with. Because there doesn't appear to be any kind of calendar on the page you linked to.

The reservation forms layouts are somewhat messed up though.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-30-2010, 08:12 PM Re: Need help with php script connecting to jscalendar
Novice Talker

Posts: 6
Name: Diane B
Trades: 0
No - not that page.
The search is working

If you are on that page (called bookonline.php) you enter dates and you get available chalets. If you click on the magnifying glass beside one of the availalbe units displayed, you get a pop up page - that's the chaletdetails.php

On that page it shows rotating pics, amenties and supposed to show a calendar showing the blocked dates.

Yu can access this same chaletdetails.phlp from the village map page by clicking a lot

Can you help?
deedles2740 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Need help with php script connecting to jscalendar
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.65451 seconds with 12 queries