[thelist] Update styles based on date with PHP?
Jono
jono at charlestonwebsolutions.com
Mon Sep 18 14:11:57 CDT 2006
> I assume that the calendar items are being generated by PHP too, right?
> Assuming straight PHP + HTML, where each row is coming from, say an array of
> "event" objects, then you would just need to modify your php to compare the
> dates and add the class. I'd put it on the <tr> so you can style all the
> children <td>'s if need be.
>
> <?php
> foreach($events as $event) {
> ?>
> <tr<?php echo(strtotime($event->date) < time() ? 'class="past"' : ''); ?>>
> ...
> </tr>
> <?php
> }
> ?>
>
No, no database, but that would be ideal - I am just good enough with
PHP (yet) to set up a db for such a thing.
I am familiar with using MySQLFront to add/edit data tables and fields,
but that is about the extent of my db skills. I'm on Chapter 6 of SAMS
teach yourself Apache, MySQL and PHP in 24 hrs. I do not know the
syntax required to pull info out of the database.
I know there ways to insert the current date with some simple PHP, so I
was thinking there might be a way to compare today's date to the one for
the events in the table. All I have at this point is a plain-old static
HTML table.
I could set up a table for Events with fields for date, location,
website, visible, etc. Perhaps a good basic setting up a database
tutorial would be good for me. Most of what I find on php.net and/or
Zend, etc. assumes I already know what they are talking about - most of
it is hard to follow for a beginner programmer. I am currently looking
at this little tutorial on Zend: http://www.zend.com/zend/art/intro.php
More information about the thelist
mailing list