Results 1 to 7 of 7

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

  1. #1
    Join Date
    Oct 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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 php). 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 toastysquirrel; 10-11-2006 at 05:12 PM. Reason: solved

  2. #2
    Join Date
    Oct 2006
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Why not just have a link above each table column pointing to the page and have a sort argument for the query...


    Example

    <A href="testpage.php?sortby=date">Date</A>

    then in the query do

    SELECT * FROM table1 WHERE etcetc... ORDER BY $_GET['sortby']

    Of course I would do some error checking in there.. but it's fairly simple to do.

    So when they click on a given column, it will sort by that column type.

  3. #3
    Join Date
    Oct 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by nelis
    Why not just have a link above each table column pointing to the page and have a sort argument for the query...


    Example

    <A href="testpage.php?sortby=date">Date</A>

    then in the query do

    SELECT * FROM table1 WHERE etcetc... ORDER BY $_GET['sortby']

    Of course I would do some error checking in there.. but it's fairly simple to do.

    So when they click on a given column, it will sort by that column type.
    Hey Nelis,

    Thanks for the suggesion, it sounds like a fairly easy enough fix for it However, from my severly limited experience with creating DBs I'm guessing that the query code you referenced is for querying a MySQL DB. Right now I'm not using one, everything's simple text fields within a PHP page plugged into nothing more then a table.

    Code:
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <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>
      <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>
      <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>
      <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>
      <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>
    Last edited by toastysquirrel; 10-10-2006 at 09:48 PM.

  4. #4
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Posted: toastysquirrel
    Right now I'm not using one, everything's simple text fields within a PHP page plugged into nothing more then a table.
    Are you refering HTML tables using which you've performed the alignment/formatting of your form elements? If yes then where exactly are you going to store the data from the user that has been entered into the form elements?

    You need to insert the data into the database firstly then only you can retrive them later for processing.

    Have you implemented the insertion of data into the database?

    The code you placed in your latest post is just shows an HTML table based one rather than a PHP one?

  5. #5
    Join Date
    Oct 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Sorry, I guess I could have been clearer in my post, it was a bit confusing.

    1) Users will not be able to enter any data, rather they will only be able to view the data that I enter.
    2) Currently there is no database, that's something I'm looking for. Perhaps I'm asking too much for something prebaked. It just seems like some an empty database with fields ripe for populating would be out there along with a simple PHP front end for viewing it on a webpage in a table.

    Since I currently don't have a database I'm fighting tooth-and-nail with a javascript to get it to work appear correctly on my site.

    I hope this post makes my plight a little clearer.

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    databases don't come set up.
    That's pointless.
    you make the tables, rows, cells, etc.
    that's why they're useful.
    take a look here and see if it may help:
    http://php-mysql-tutorial.com
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #7
    Join Date
    Oct 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yeah, I somewhat figured a "generic database" wasn't something I'd be likely to find, not a good quality one anyway. I use about three other databases on my site (or is it four?) and was hoping, "hey, maybe some else has created something for what I'm looking for?" Anyway, someone pointed me to a decent javascript that handles the sorting very nicely... I had to monkey my way around it and figure out how to maintain the reference to my CSS's classes since the javascript required assigning its own classes to those columns... but I finally got it working good enough. So, one more milestone behind me.

    I really appreciate the help you guys sent my way, every little bit does help; thanks everyone!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •