Jump to content

Recommended Posts

Hi,

What I have is a table (code below) and it is for an events page. What I want is after the date has gone, it changes the whole row to grey. ( #666666 ). Thanks for your help,

From

Cal

P.S. I'm a novice at PHP & have no access to mySQL

 

Events Table Code:

<table width="567" border="1" align="center" cellpadding="0" cellspacing="0" id="events">
                <tr bgcolor="#FF9933">
                  <td colspan="2"><div align="center">
                    <p><strong>JUNE</strong></p>
                    </div></td>
                  </tr>
                <tr>
                  <td width="120"><div align="center">
                    <p>Sun 3rd June </p>
                  </div></td>
                  <td width="441"><div align="center">
                    <p>Int. Comp</p>
                  </div></td>
                </tr>
                <tr>
                  <td width="120"><div align="center">
                    <p>Sat 9th June </p>
                  </div></td>
                  <td><div align="center">
                    <p>Class 3 Judges Course</p>
                  </div></td>
                </tr>
                <tr>
                  <td width="120"><div align="center">
                    <p>Sun 10th June </p>
                  </div></td>
                  <td><div align="center">
                    <p>Comp</p>
                  </div></td>
                </tr>
                <tr>
                  <td width="120"><div align="center">
                    <p>Sun 24th June </p>
                  </div></td>
                  <td><div align="center">
                    <p>First Aid Course</p>
                  </div></td>
                </tr>
                <tr bgcolor="#FF9933">
                  <td colspan="2"><div align="center">
                    <p><strong>JULY</strong></p>
                  </div></td>
                  </tr>
                <tr>
                  <td width="120"><div align="center">
                    <p>Sun 1st July 07 </p>
                  </div></td>
                  <td><div align="center">
                    <p>Comp </p>
                  </div></td>
                </tr>
                <tr>
                  <td width="120"><div align="center">
                    <p>Sat 7th & <br>
                      Sun 8th July </p>
                  </div></td>
                  <td><div align="center">
                    <p>Seminar 321</p>
                  </div></td>
                </tr>
                <tr>
                  <td width="120"><div align="center">
                    <p>Sun 15th July </p>
                  </div></td>
                  <td><div align="center">
                    <p>Grading 8 </p>
                  </div></td>
                </tr>
                <tr>
                  <td width="120"><div align="center">
                    <p>Sun 22nd July </p>
                  </div></td>
                  <td><div align="center">
                    <p>Competition 198</p>
                  </div></td>
                </tr>
                       </table>

Link to comment
https://forums.phpfreaks.com/topic/54441-changing-items-after-a-date/
Share on other sites

Convert the text date to a date and compare it to the current date.

 

How are retreiving these dates?

 

To convert from text, something like:

$months = array('January' => 1,'February' => 2,'March'=>3, 'April'=>4, 'May'=>5, 'June'=>6, 'July'=>7, 'August'=>8, 'September'=>9, 'October'=>10, 'November'=>11, 'December'=>12);
$textdate = 'Sun 3rd June';
preg_match('/\w{3} (\d{1,2}) (\w+)/',$textdate,$matches);
$numdate = sprintf('%02d%02d',$months[$matches[2]],$matches[1]);
if ($numdate > date('md')) echo "Whatever you want here.";

I don't understand what that code does.

I am not too sure whether I explained this right or not,

I have many rows, each with two columns, in one column there is a date (in format of Sun 10th June) and in the second column there is information about the event.

After the date has passed (and abviously the event has finished too, I want the background in the two cells to turn grey ( #666666 )

(the code for the table is above)

Cheers, from

Cal

If you are retrieving the rows from a database, it would be trivial to decide if the date has passed.

 

If you only have a static HTML table you're reading the date/event from, then you'll need something like I posted above to turn the date string into a number in order to compare it to the current date.  Once the comparison has been made, you can then print it whatever color you please.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.