Jump to content

I dont want the color to be repeated


npsari

Recommended Posts

Hi there

I have a table called name

In which, i have a row called names

 

i use this little code to show the last 3 names

 

$con=mysql_connect("$Connect", "$Name", "$Pass"); 
mysql_select_db("$Database", $con); 

$q = "SELECT * FROM name LIMIT 3;";
$res = @mysql_query($q);
while($r = @mysql_fetch_array($res)){	
print"<FONT style=\"font-size:11px\" color=\"#000000\" face=\"Arial\">$r[name]</FONT><br>";
}

 

but i dont want all names to be black color

I want the first name black (000000)

the second red (ff0000)

the third blue (0000FF)

 

How can i write the above code plz

Link to comment
https://forums.phpfreaks.com/topic/92148-i-dont-want-the-color-to-be-repeated/
Share on other sites

Here is one more approach without the array:

 

Insert this line after the "while" statement

 


$colors= ($colors== "#F1F5F8" ? "#006600" : "#F1F5F8");  // change colors to suit your page design
echo "<p style=\"color: ".$colors.";\">".$row['Name']."</p>";

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.