473,396 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Using css to alternate dynamic table row colors

I have a problem with alternating the rows of my php dynamic table. I saw an example here which I was able to use but I dont understand how to switch between between html and the php on the <tr class= <?php "' . $class .'" ?>' altrow is my css class definition. below is my mark up:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <tr>
  3.     <th scope="col">Trackid</th>
  4.        <th scope="col">NMEA</th>
  5.       <th scope="col">Date</th>
  6.  
  7. </tr>
  8.     $result = mysql_query($sql, $link);
  9.     $i = 0;
  10.     if (!$result) {
  11.         die("Query to show averages from table failed");
  12.     }
  13.     while ($row = mysql_fetch_assoc($result)){
  14.         $class = ($i++ % 2) ? 'altrow' : '';
  15. ?>
  16.     <tr class= <?php "' . $class .'" ?>>';
  17.     <td><?php echo $row['Trackid']; ?></td>
  18.       <td><?php echo $row['NMEA']; ?></td>
  19.       <td><?php echo $row['Date']; ?></td>
  20.  
  21. </tr>
  22. <?php } ?>
  23. </table>
Can someone please show how to achieve this alternation? Thanks
Oct 24 '10 #1
1 2349
Dormilich
8,658 Expert Mod 8TB
you have the alteration on line 14, you only need to echo it.
Oct 25 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ex-Em-El | last post by:
let say i have this xml file : xml: <?xml version="1.0" standalone="yes"?> <aaa> <ppp> <po> <co>c</co> <do>int</do>
1
by: Juha Rossi | last post by:
Hi all, Im designing a web site and had an idea of nicely centered dynamic table instead of using frames. I would like to use html table like below: -----------------------------------------...
1
by: dschectman | last post by:
I have an interesting issue. I need to implement a dynamic table to mimic a select list. Each time you double click from the master list, a row is added to the list of selected items. The list...
1
by: E.U. | last post by:
Hi, I an using MS-Access in order to build a site. I have this item that can have upto 10 pictures (might have none) I want to design a dynamic table which has the ID of the item at the first...
1
by: russ | last post by:
Hi all, Here's a problem I'm having with a dynamic table. Following the guidelines here (http://www.codeproject.com/aspnet/dynamiccontrols.asp), which make perfect sense. The problem is that...
2
by: dschectman | last post by:
This appears to be a feature of IE JavaScript. I am running IE 6.0 with the latest patches from Microsoft. Are there any workarounds other than re-coding the source HTML to place all the...
2
by: H.c.m. Raaijmaakers | last post by:
Hi, The user can create a dynamic table. In every row are 5 input text boxes. If the second text box gets a onblur event then the value of the third box needs to become the value of the first...
1
by: eureka | last post by:
Hi folks, I am working on a webapplication using Jsp and JS. On my main Jsp(Jsp1) I have a table which is created dynamically inside a <divand contains all the backend-table's records as rows,...
0
by: Dhanasekaran B | last post by:
Dear I need to create dynamic temproray table for reporting purpose.I did't have permission for DDL commands. Without Database Administrator permission, i need to create temp. Dynamic table. (or)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.