Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8038557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:16:28+00:00 2026-06-05T03:16:28+00:00

I have a table that get its rows from a MYSQL database <table id=table1>

  • 0

I have a table that get its rows from a MYSQL database

<table id="table1">
<?php
// Connect to database server
    mysql_connect("localhost", "root", "asnaeb") or die (mysql_error ());
// Select database
        mysql_query("SET NAMES `utf8`"); // UTF 8 support!!
    mysql_select_db("scores") or die(mysql_error());
// SQL query
    $strSQL = "SELECT * FROM latest";
// Execute the query (the recordset $rs contains the result)
    $rs = mysql_query($strSQL);
// Loop the recordset $rs
// Each row will be made into an array ($row) using mysql_fetch_array
    while($row = mysql_fetch_array($rs)) { 
// Write the value of the column FirstName (which is now in the array $row) 
?>

<?php echo $row['Header'].""; ?>
<tr>
<td id='date'><?php echo $row['Date'].""; ?></td>
<td id='time'><?php echo $row['Time'].""; ?></td>
<td id='hometeam'><?php echo $row['HomeTeam'].""; ?></td>
<td id='score'><?php echo $row['Score'].""; ?></td>
<td id='awayteam'><?php echo $row['AwayTeam'].""; ?></td>
<td id='other'><?php echo $row['Other'].""; ?></td>
</tr>

<?php } mysql_close(); ?>
</table>

i have 2 css class called “A” and “B” for Odd Rows and Even Rows

i currently getting this done by replacing <tr> with <tr class='<?php echo $row['Row'].""; ?>'> and i have in my Database table a column “Row” which i add in A or B for even or odd row… the problem is if i wanna delete or add a new row between one of these i will have to change all the A and B in the other.

I have seen in another questions many way to do that in javascript or jquery but for a normal table with TR’s which is not my case…(tried some of these scripts but couldn’t get it fixed)

So what i want an easier way to do that Even and Odd rows, Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T03:16:29+00:00Added an answer on June 5, 2026 at 3:16 am

    You can add those classes using jQuery easily like this

    $(function(){
      $('#table1 tr:odd').addClass('A');
    
     // for even
    
     $('#table1 tr:even').addClass('B');
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large table that get populated from a view. This is done
I coded a php page that displays information from a mysql database neatly into
I have a MySQL database that has over 9000 rows with 10 fields. It
i have a strange situation: I'm using jpa/hibernate to get rows from a mySql
I have a mysql MyISAM table with many rows that contain information about places,
I have table that I insert data with following query (from c# code): INSERT
I have a MySQL db, with a functioning table. I am trying to get
I currently have a script that takes 1,000 rows at a time from a
I have a simple MySQL 5 database that consists of id - Int -
I have a table that acts as a dropbox for files that get automatically

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.