Eka
05-04-2006, 01:29 PM
What I have here is a silly piece of code. Why is it silly? I know little to nothing about programming, It ought to be silly!
$currentt = time();
echo $info_message;
if (count($u_ids))
{
echo "$w_search_results<br>";
echo "<table>";
for ($i=0;$i<count($u_ids);$i++)
{
echo "<tr><td><a href=\"fullinfo.php?user_id=".$u_ids[$i]."&session=$session\">".$u_names[$i]."</a></td> <td>\n";
$diffe = $currentt - $last_visit[$i];
if ($diffe < 1000000)
echo "<font color=00ffff>";
else if ($diffe < 2000000)
echo "<font color=00eeee>";
else if ($diffe < 3000000)
echo "<font color=00dddd>";
else if ($diffe < 4000000)
echo "<font color=00cccc>";
else if ($diffe < 5000000)
echo "<font color=00bbbb>";
else if ($diffe < 6000000)
echo "<font color=00aaaa>";
else if ($diffe < 7000000)
echo "<font color=009999>";
else if ($diffe < 8000000)
echo "<font color=008888>";
else if ($diffe < 9000000)
echo "<font color=007777>";
else
echo "<font color=006666>";
print "Last Visited: <font face=Courier>" . date("M-d-Y H:i:s ", $last_visit[$i]);
What I'm trying to do here, is to make the color of the text go from brightest to dimest according to the last time they visit. $last visit respersent the unix time code of the last time they log in, and this code basically output everyone's name and the time they login.
How do I improve on this? Surely I want more color shade then the number if IF statment allow, but thinking about how to translate the $diffe, as in the number of seconds between now and the last time they login, into a proper format that font color will use, is giving me a hard time.
Sorry if this seem beginner, but I have no PHP courses and other programming courses. Just want to start impoving code and learn from there.
Thank you in advance for your advice!
$currentt = time();
echo $info_message;
if (count($u_ids))
{
echo "$w_search_results<br>";
echo "<table>";
for ($i=0;$i<count($u_ids);$i++)
{
echo "<tr><td><a href=\"fullinfo.php?user_id=".$u_ids[$i]."&session=$session\">".$u_names[$i]."</a></td> <td>\n";
$diffe = $currentt - $last_visit[$i];
if ($diffe < 1000000)
echo "<font color=00ffff>";
else if ($diffe < 2000000)
echo "<font color=00eeee>";
else if ($diffe < 3000000)
echo "<font color=00dddd>";
else if ($diffe < 4000000)
echo "<font color=00cccc>";
else if ($diffe < 5000000)
echo "<font color=00bbbb>";
else if ($diffe < 6000000)
echo "<font color=00aaaa>";
else if ($diffe < 7000000)
echo "<font color=009999>";
else if ($diffe < 8000000)
echo "<font color=008888>";
else if ($diffe < 9000000)
echo "<font color=007777>";
else
echo "<font color=006666>";
print "Last Visited: <font face=Courier>" . date("M-d-Y H:i:s ", $last_visit[$i]);
What I'm trying to do here, is to make the color of the text go from brightest to dimest according to the last time they visit. $last visit respersent the unix time code of the last time they log in, and this code basically output everyone's name and the time they login.
How do I improve on this? Surely I want more color shade then the number if IF statment allow, but thinking about how to translate the $diffe, as in the number of seconds between now and the last time they login, into a proper format that font color will use, is giving me a hard time.
Sorry if this seem beginner, but I have no PHP courses and other programming courses. Just want to start impoving code and learn from there.
Thank you in advance for your advice!