PHP Change Row Colors

Just an easy way to change every other row from database using php
Ok. Today I will show you how to change the colors of each row that is return from the our database. The first thing will will do is include the connect to the database. Second we will set the $r variable to 0. Next get the rows from the database and put them in a variable called $title. Now in our while loop we are gonna add 1 to the $r variable. Then our if statement. If the variable $r equals 2 display class row_a which is the class for the first row. And if it does not equal 2 display class row_b. So now every other row will be class row_b. Now let’s put it all together.

Tagged with:

View all contributions by


Related Articles


Stay connected with us

Add us on Google+

Follow us on Facebook

Follow us on Twitter

Get updates via RSS

Get email updates


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">