Page 1 of 1

PHP/MYSQL/CSS

Posted: Sun Aug 16, 2009 9:54 am
by Aravinthan
Hi guys,

Here is my problem,

I am extracting data from a MYSQL table and formatting it into a table.

But what I want is that the first row should be:

Code: Select all

 
<tr>
 
The second one to be:

Code: Select all

 
<tr class='odd' >
 
Third one:

Code: Select all

 
<tr>
 
And so on.... I am pretty sure its simple ,but I cant put my finger on it.... :banghead: :banghead: :banghead:

Re: PHP/MYSQL/CSS

Posted: Sun Aug 16, 2009 11:25 am
by JAB Creations
So you're using A and B to generate C though you won't show us A and B? Hm...

It looks like you're trying to generate alternate rows; I'm not sure how I would approach that myself with what I currently know about existing PHP functions though I would start by searching for, 'PHP odd even' on a search engine. :wink:

Here are a couple snippets I came across that you might want to test out...

Code: Select all

if ($i % 2) {
echo "$i is odd";
} else {
echo "$i is even";
}
 

Code: Select all

$i = 10;
if ( $i&1 )
{
echo "$i is odd";
}
else
{
echo "$i is even";
}
Let me know if that works out. :)

Re: PHP/MYSQL/CSS

Posted: Mon Aug 17, 2009 9:10 am
by JAB Creations
McInfo wrote:There is also the pure CSS solution. http://www.w3.org/Style/Examples/007/evenodd
True, but Aravinthan may need to support outdated browsers. :?