PHP/MYSQL/CSS

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Aravinthan
Forum Commoner
Posts: 84
Joined: Mon Jan 28, 2008 6:34 pm

PHP/MYSQL/CSS

Post 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:
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: PHP/MYSQL/CSS

Post 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. :)
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: PHP/MYSQL/CSS

Post 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. :?
Post Reply