php hcalendar array issue
Posted: Sat Feb 10, 2007 8:41 pm
feyd | Please use
Please if you can help me do !
Thanks
David Swain
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
HELP !!!!!
It my first post here so I thought I would start in the traditional way !
I’m fairly new to web design and even newer to php. Basically im setting up a site and want an event calendar marked up in hCalendar. i have a mysql table with the following fields :
ID_cal smallint(6) No auto_increment
startDate_cal datetime Yes NULL
endDate_cal datetime Yes NULL
summary_cal varchar(255) utf8_unicode_ci Yes NULL
summaryURL_cal varchar(255) utf8_unicode_ci Yes NULL
location_cal varchar(255) utf8_unicode_ci Yes NULL
locationURL_cal varchar(255) utf8_unicode_ci Yes NULL
description_cal varchar(10000) utf8_unicode_ci Yes NUL
inclusive_cal tinyint(1) No
public_cal tinyint(1) No
Now I have the system sort of working… I can get it to spit out the results of the database WITH APPRORIATE MARKUP. The fields are I think fairly self explanatory with the exception of INCLUSIVE_CAL and PUBLIC_CAL. Public is to show the results for the public, some events are for me only, no problems with that. Inclusive_Cal is the one giving me problems.
Basically I do performances (acting gigs etc) and quiet often want to supply a range of dates; e.g. a run of shows for a week starting at 7.30 every night.
What I want to do is instead of adding 7 or 8 events to the table which seems inefficient is add one and get the code to ‘spit out‘ 7 discrete events. There are also things like matinees to consider which start at a different time. What i was thinking (using the above example) is specify the date range of a week as one event in the table and then add the matinee as a separate events: eg:
[b]Event 1[/b]
start date 2007-03-05 19:45:00
end date 2007-02-10
inclusive yes
rest of event details..
[b]Event 2[/b]
start date 2007-03-10 19:45:00
end date NULL
inclusive NO
rest of event details….
Then i basically want the php code to get the events from the table, create 7 events from the results of event one, an eight from the results of event 2, sort the accordingly to date and print to screen.
Sounds simple enough, and im sure it is the only problem is I have no idea how to do it !
In the example http://davidswain.co.uk/cal-include.php
I have got working I have used mysql_fetch_array to get the results from the table which will them put them out as a event with a date range of a week.
Yes it is but ugly and unformatted by why worry about that before it works ?
My code is:Code: Select all
<?php require($_SERVER['DOCUMENT_ROOT']."/includes/inc-config.php"); ?>
<?php require($_SERVER['DOCUMENT_ROOT']."/includes/inc-db-functions.php"); ?>
<?php
$sql = 'SELECT * from tbl_event WHERE startDate_cal > ' . date(y) . ' ORDER BY startDate_cal ASC';
$result = db_connect($sql);
while ($row = mysql_fetch_array($result)) {
?>
<span class="vevent">
<a href=" <?php echo $row["summaryURL_cal"]; ?>" title="<?php echo $row["summaryURL_cal"]; ?>" class="summary url"><?php echo $row["summary_cal"]; ?></a></strong>
<abbr title="<?php echo date(c,strtotime($row["startDate_cal"])) ?>" class="dtstart"><?php echo date($row["startDate_cal"]); ?></abbr>
<?php
if ($row["endDate_cal"] == NULL) {
}
elseif (date($startDate) == date($endDate)) {
echo "–" . "<abbr title=\"" . date(c, strtotime($row["endDate_cal"])) . "\" class=dtend >" . $row["endDate_cal"] . "</abbr>";
}
else {
echo "–<abbr title=" . date(c, strtotime($row["endDate_cal"])) . " class=dtend>" . $row["endDate_cal"] . "</abbr>";
}
?>
<a href="<?php echo $row["locationURL_cal"]; ?>" class="location"><?php echo $row["location_cal"]; ?></a>
<span class="description"><?php echo $row["description_cal"]; ?></span></span><br />
<?php
}
?>Thanks
David Swain
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]