/    Sign up×
Community /Pin to ProfileBookmark

Date defining colour

Howdy,

Ok I have created a mySQL table to hold clients urls and renewal dates.

What I am wanting to do is when the date of renewal is within 1 month of the present date, to change the font colour of that cell to Red.

Hope that makes sence!

Code so far:

[code=php]<?php
$host=”127.0.0.1″; $username=”username”; $password=”password”; $db_name=”db_name”; $tbl_name=”Hosting”;

mysql_connect(“$host”, “$username”, “$password”)or die(“cannot connect”);
mysql_select_db(“$db_name”)or die(“cannot select DB”);

$result = mysql_query(“SELECT * FROM Hosting ORDER BY Renewal”)
or die(mysql_error());

echo “<table border=’1px’><tr>”;
for($i = 0; $i < mysql_num_fields($result); $i++){
echo “<th>”.mysql_field_name($result, $i).”</th>”;
}
echo “</tr>”;
while($row = mysql_fetch_array($result)){
echo “<tr>”;
for($i = 0; $i < mysql_num_fields($result); $i++){
echo “<td>”. $row[$i] .”</td>”;
}
echo “</tr>”;
}

echo “</table>”;

?>[/code]

So far I have it to order the table so the next Renewal date is at the top of the table.

Any help wud be great, Thanks.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@DetectAug 01.2007 — So, you'll first need to calculate the difference in days between the renewal date and now for each row. You can do this in PHP or MySQL (datediff). Then add a conditional so if the difference is less than 30 days (or whatever you choose), change the style (color) of the text inside the TD.
Copy linkTweet thisAlerts:
@docpepperauthorAug 02.2007 — Hi, thanks for reply!

Yeah I kind of understand the logic on what I need to do, Im just not sure how to implement it into the PHP I have.
×

Success!

Help @docpepper spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...