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
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>";

Link to comment
Share on other sites

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.