02.06.2013 Views

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

162<br />

CHAPTER 4 ■ BUILD AN EVENTS CALENDAR<br />

}<br />

?><br />

}<br />

*/<br />

if ( isset($event[0]) )<br />

{<br />

return new Event($event[0]);<br />

}<br />

else<br />

{<br />

return NULL;<br />

}<br />

When called, this method will return an object (for the ID of 1) that looks like this:<br />

Event Object<br />

(<br />

[id] => 1<br />

[title] => New Year's Day<br />

[description] => Happy New Year!<br />

[start] => 2010-01-01 00:00:00<br />

[end] => 2010-01-01 23:59:59<br />

)<br />

Creating a Method to Generate Markup<br />

Now that an array of a single event’s data is available, you can build a new public method to format the<br />

event data into HTML markup.<br />

This method will be called displayEvent(); it will accept an event’s ID <strong>and</strong> generate HTML markup<br />

using the following steps:<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!