How to create a sortable table?
-
I am trying to create a table that users can sort by column header. The table is generated with the following code:
<table border="0" width="100%" valign="middle" cellpadding="10" cellspacing="0"> <thead> <tr> <th>Partner Name</th> <th>Law Firm</th> <th>Location</th> <th>Comments</th> <th style="padding-left:10px;">Rating</th> </tr> </thead> <?php $rowclass=0; while (have_posts()) : the_post(); $firm = get_post_meta($post->ID, 'firm', true); $location = get_post_meta($post->ID, 'location', true); ?> <!-- BEGIN post --> <tbody> <tr class="row<?=$rowclass ?>"> <td><a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></td> <td><?php if($firm !=='') {echo $firm;} ?></td> <td><?php if($location !=='') {echo $location;} ?></td> <td align="center"><?php comments_number('0','1','%'); ?> <td><?php wp_gdsr_render_article(); ?></td> </tr> </tbody> <?php $rowclass = 1-$rowclass; ?> <?php endwhile; ?> </table>
As you can see the table is produced within the Loop. I have tried a variety of javascript table sorter scripts and have been unsuccessful so far.
If you would like to see the live site go to rateapartner dot com and click on one of the categories in the left side bar.
Thanks.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘How to create a sortable table?’ is closed to new replies.