Page 1 of 1
PHP's code question
Posted: Sat Apr 16, 2011 9:29 pm
by phpbluee
I've the following code, there is an error but I can't quite figure it out. If someone see something wrong with the code, please shed some light. Thanks...
P.S. I think the error is around the string $suffix.
Code: Select all
<?
$startHourOfWeekPlanner = 8; // Start hour of week planner
$endHourOfWeekPlanner = 21; // End hour of weekplanner.
$date = mktime($startHourOfWeekPlanner,0,0,5,5,2006);
for($no=$startHourOfWeekPlanner;$no<=$endHourOfWeekPlanner;$no++){
$hour = $no;
// Remove these two lines in case you want to show hours like 08:00 - 23:00
$suffix = date("a",$date);
$hour = date("g",$date);
// $suffix = "00"; // Enable this line in case you want to show hours like 08:00 - 23:00
$time = $hour."<span class=\"content_hour\">$suffix</span>";
$date = $date + 3600;
?>
<div class="calendarContentTime"><? echo $time; ?></div>
<?
}
?>
Re: PHP's code question
Posted: Sat Apr 16, 2011 10:39 pm
by fugix
what is the exact error that you are receiving?
Re: PHP's code question
Posted: Sun Apr 17, 2011 7:08 am
by phpbluee
[text]
I can't seem to post screen capture here. But here the text error below. Thanks.
$suffix"; $date = $date + 3600; ?>
[/text]
Re: PHP's code question
Posted: Sun Apr 17, 2011 8:54 am
by Peter Kelly
Code: Select all
<?
$startHourOfWeekPlanner = 8; // Start hour of week planner
$endHourOfWeekPlanner = 21; // End hour of weekplanner.
$date = mktime($startHourOfWeekPlanner,0,0,5,5,2006);
for($no=$startHourOfWeekPlanner;$no<=$endHourOfWeekPlanner;$no++){
$hour = $no;
// Remove these two lines in case you want to show hours like 08:00 - 23:00
$suffix = date("a",$date);
$hour = date("g",$date);
// $suffix = "00"; // Enable this line in case you want to show hours like 08:00 - 23:00
$time = $hour."<span class='content_hour'>$suffix</span>";
$date = $date + 3600;
?>
<div class="calendarContentTime"><? echo $time; ?></div>
<?
}
?>
Try that
Re: PHP's code question
Posted: Sun Apr 17, 2011 9:00 am
by phpbluee
Hi Peter, you posting contain some #39, #40, #41 and etc... What are they represent?
Re: PHP's code question
Posted: Sun Apr 17, 2011 9:11 am
by phpbluee
I tried that and it's still not working.
Re: PHP's code question
Posted: Sun Apr 17, 2011 9:28 am
by Peter Kelly
Sorry I used quick reply and it seemed to have buggered it up try this.
Code: Select all
<?
$startHourOfWeekPlanner = 8; // Start hour of week planner
$endHourOfWeekPlanner = 21; // End hour of weekplanner.
$date = mktime($startHourOfWeekPlanner,0,0,5,5,2006);
for($no=$startHourOfWeekPlanner;$no<=$endHourOfWeekPlanner;$no++){
$hour = $no;
// Remove these two lines in case you want to show hours like 08:00 - 23:00
$suffix = date("a",$date);
$hour = date("g",$date);
// $suffix = "00"; // Enable this line in case you want to show hours like 08:00 - 23:00
$time = $hour."<span class='content_hour'>$suffix</span>";
$date = $date + 3600;
?>
<div class="calendarContentTime"><? echo $time; ?></div>
<?
}
?>
Re: PHP's code question
Posted: Sun Apr 17, 2011 9:47 am
by phpbluee
Sorry, it still not working. It doesn't like the following line for some reason when I did a view source.
Code: Select all
$time = $hour."<span class='content_hour'>$suffix</span>";
Re: PHP's code question
Posted: Sun Apr 17, 2011 10:06 am
by Peter Kelly
It works fine for me.
Code: Select all
<?
$startHourOfWeekPlanner = 8; // Start hour of week planner
$endHourOfWeekPlanner = 21; // End hour of weekplanner.
$date = mktime($startHourOfWeekPlanner, 0, 0, 5, 5, 2006);
for ($no = $startHourOfWeekPlanner; $no <= $endHourOfWeekPlanner; $no++)
{
$hour = $no;
// Remove these two lines in case you want to show hours like 08:00 - 23:00
$suffix = date("a", $date);
$hour = date("g", $date);
// $suffix = "00"; // Enable this line in case you want to show hours like 08:00 - 23:00
$time = $hour . "<span class='content_hour'>$suffix</span>";
$date = $date + 3600;
?>
<div class="calendarContentTime"><?
echo $time;
?></div>
<?
}
?>
shows in the source view
Code: Select all
<div class="calendarContentTime">8<span class='content_hour'>am</span></div>
<div class="calendarContentTime">9<span class='content_hour'>am</span></div>
<div class="calendarContentTime">10<span class='content_hour'>am</span></div>
<div class="calendarContentTime">11<span class='content_hour'>am</span></div>
<div class="calendarContentTime">12<span class='content_hour'>pm</span></div>
<div class="calendarContentTime">1<span class='content_hour'>pm</span></div>
<div class="calendarContentTime">2<span class='content_hour'>pm</span></div>
<div class="calendarContentTime">3<span class='content_hour'>pm</span></div>
<div class="calendarContentTime">4<span class='content_hour'>pm</span></div>
<div class="calendarContentTime">5<span class='content_hour'>pm</span></div>
<div class="calendarContentTime">6<span class='content_hour'>pm</span></div>
<div class="calendarContentTime">7<span class='content_hour'>pm</span></div>
<div class="calendarContentTime">8<span class='content_hour'>pm</span></div>
<div class="calendarContentTime">9<span class='content_hour'>pm</span></div>
Re: PHP's code question
Posted: Sun Apr 17, 2011 10:25 am
by fugix
to answer your question from before blue...the ( and ) are HTML's way of inserting parenthesis.
Re: PHP's code question
Posted: Sun Apr 17, 2011 10:26 am
by fugix
#40 and #41...changed them to actual parenthesis above
Re: PHP's code question
Posted: Sun Apr 17, 2011 10:32 am
by phpbluee
Humm, I don't know what's going on here. I downloaded WAMP and installed on my local computer and run this script from there. I don't know if there is anything that causes this to not work. If anyone else know anything please post some tips. Thanks...
