how to Show red color in even cell by using php and jquery

I written below program
I want to show red color on table cell which are even in order using jquery.but program is not executing properly.

[size=10pt]

even demo
    <?php

$con= mysql_connect(“10.20.41.241”,“Appcreator”,“Appcreat@r”);
$list=mysql_listdbs($con);
$i=0;
$cnt = mysql_num_rows($list);
echo “

”;
echo"";
while ($i< $cnt)
{
 echo "<tr><td>".substr(mysql_db_name($list,$i),0,5)."</td>></tr>";
 
$i++;

}
echo “

DatabasesName
”;
?>
[/size]

First I have to give my usual speech “Don’t use mysql instead use mysqli or PDO”

OK, now that is out of the way, put you jQuery in the body of the html, preferably at the bottom. Second get your jQuery script to work the way you want it to, then you can interject a MySQL database using PHP. Doing it this way will cause a lot less headaches and be easier to debug.

Here’s an example that I think that you are after:

[code]<!doctype html>

even demo table { border-spacing: 0.5rem; border-collapse: collapse; width: 600px; margin: auto; } th, td { border: 2px solid #2e2e2e; padding: 20px; }
Name ID Favorite Color
Jim 00001 Blue
Sue 00002 Red
Barb 00003 Green
Lisa 00002 Pink
John 00003 magenta
[/code]

It looks like it’s odd but it is actually even, for it starts with the rows and not the header of the table.

but how can i embed my php code into this?

Just a quick one… it appears you’ve left your connection string in there… username/password/ip. I’d advise you to remove them unless they’ve already been changed.

For the odd/even rows, there’s a built-in function in CSS3 which will allow this:

[php]td:nth-child(odd)
{
background:#ff0000;
}
td:nth-child(even)
{
background:#0000ff;
}[/php]
http://www.w3schools.com/cssref/sel_nth-child.asp

Sponsor our Newsletter | Privacy Policy | Terms of Service