Web Analytics Made Easy -
StatCounter [Resolved] Looking for Script to sort table data (& populate database) - CodingForum

Announcement

Collapse
No announcement yet.

[Resolved] Looking for Script to sort table data (& populate database)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Resolved] Looking for Script to sort table data (& populate database)

    Edit - Got the code from the developer

    I'm wondering if anyone might know of a prebuilt script that I can use to do the following:

    There are two things I want to do: (1) Make the data in a table on one of my pages sortable. (2-optional) Update/enter the data in a MySQL database.

    Currently I have a page on my site that displays data in a table consisting of five colums that include values of text (including an href), numeric/decimal, and date. Right now, whenever I need to update the table I have to add a new row and populate the colums with their data (via html). All the info is housed on that webpage.

    This seems like it should be something fairly simple, however I'm having a hellofa time finding a prebaked database/script to impliment at least one of these features. If I had the time I would learn how to code it all myself, but I'm looking at a time frame of a couple days before I need it online.

    Does anyone have any ideas of a script that, at the very least, would do the table sorting? Preferably handling the database as well (though optional, like I mentioned). Did I mention "free" would also be a nice feature? I've searched online and found a few that handle the sorting but their coding seems a bit off and usually ends up screwing up the java on the rest of my page.

    I'm open to any thoughts or suggestions and I really appreciate even the most miniscule amount of help
    Last edited by toasty; Oct 11, 2006, 01:42 PM.

  • #2
    Why not post what you've got thats close.
    Lets see if we can get it to work.

    Comment


    • #3
      Hey Cyber, here's a snippet of the code that comprises my table, though it only shows a couple of the rows. If you look at the format you'll get an idea of what the whole table looks like but I didn't want to take up a ton of space in this post with duplication. The #s in some of the lines are for reference for this post only.
      Code:
      #01 <table width="564" border="0" cellpadding="0" cellspacing="0" class="sr_archiveborders">
      #02 <tr>
      #03  <td colspan="5" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      #04<tr>
      #05  <td width="100%" align="left" valign="top" class="sr_game_name">Game Name</td>
        <td align="left" valign="top" class="sr_archive_divider"><img src="../images/reviews/archive_dividers.gif" alt="divider" width="1" height="19" /></td>
      #07 <td align="center" valign="top" class="sr_platform">Platform</td>
        <td align="left" valign="top" class="sr_archive_divider"><img src="../images/reviews/archive_dividers.gif" alt="divider" width="1" height="19" /></td>
      #09  <td align="center" valign="top" class="sr_platform">Rating</td>
        <td align="left" valign="top" class="sr_archive_divider"><img src="../images/reviews/archive_dividers.gif" alt="divider" width="1" height="19" /></td>
      #11  <td align="center" valign="top" class="sr_date">Date</td>
        <td align="left" valign="top" class="sr_archive_divider"><img src="../images/reviews/archive_dividers.gif" alt="divider" width="1" height="19" /></td>
      #13  <td align="right" valign="top" class="sr_download">Download</td>
      </tr>
      <tr>
        <td colspan="2" align="left" valign="middle" class="sr_gametd"><a href="#" class="sr_gametext">Tony Hawk's Pro Skater 3</a></td>
        <td colspan="2" align="center" valign="middle" class="sr_platformtd">PS2</td>
        <td colspan="2" align="center" valign="middle" class="sr_platformtd"><strong>10.0</strong></td>
        <td colspan="2" align="right" valign="middle" class="sr_datetd">Oct 29, 2004</td>
        <td align="right" valign="middle" class="sr_downloadtd"><a href="#" class="sr_gametext">48.0 mb</a></td>
      </tr>
      <tr>
      <td colspan="2" align="left" valign="middle" class="sr_gametd"><a href="#" class="sr_gametext">Chrono Cross </a></td>
        <td colspan="2" align="center" valign="middle" class="sr_platformtd">PS</td>
        <td colspan="2" align="center" valign="middle" class="sr_platformtd"><strong>10.0</strong></td>
        <td colspan="2" align="right" valign="middle" class="sr_datetd">Jan 6, 2000</td>
        <td align="right" valign="middle" class="sr_downloadtd"><a href="#" class="sr_gametext">43.1 mb</a></td>
      </tr>
      Someone on another forum directed me to a rather nice javascript that functionally works however there's a problem in that the formatting from the script greatly conflicts with the appearance setup by my style sheet. I've included the script for the sake of being thorough.

      So I guess I'm at what I see to be a four-way fork in the road.
      1) I can continue looking for a script that will do what I want in terms of sorting the data in my table in HTML.
      2) Since this script works, figure out how to get it to stop interfering with my css file.
      3) Keep searching for a script that makes use of MySQL so I can store the info in a DB and then figure out some way for the users to sort the data on the page.
      4) Obviously keep listening to any suggestions.

      Like I was saying, the script that I'm futzing around with now does work, however it completely screws up the formatting established by my internal CSS file. The code I provided above is my page's original code and does not include anything associated with the javascript file.

      To include the javascript I made the following changes:
      a) In the head tag I inserted the code src="./tablesort.js" inside the script tag.
      b) On line #3 of the code above I modified the table tag to:
      Code:
      <table id="theTable" width="100%" border="0" cellspacing="0" cellpadding="0" class="sortable-onload-4 rowstyle-alternative no-arrow">
      Then for the colums that I wanted to make sortable (lines #5,7,9,11,13 labled above). I changed the "td" tags to "th" and added the class="sortable" code.

      The negative effect this has is it makes all the colum header text appear like links, which isn't what I want; and screws up the height and width of the cells that the headers and the data appear in.

      If you've any thoughts at all, you'll have made my day. Thanks again Cyber, and anyone else too.
      Attached Files

      Comment


      • #4
        Thanks for taking the time to look over post Cyber, I really do appreciate it. I'm happy to report that I was able to get in touch with the script's developer and, though the code is a bit sloppy, it works good enough. I'll still fine tune it, but that's one more milestone behind me now.

        Comment

        Working...
        X