Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Table Talk

  1. #1
    Regular Coder
    Join Date
    May 2007
    Location
    Manteca, CA
    Posts
    219
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Table Talk

    This may be somewhat philosphical and involve a number of questions but... first, here's what I'm looking for...

    A very easy-to-reuse scrollable list (hopefully, one call to a javascript function will do the trick - with the addition of setting various parameters). I'd rather not have to mess with HTML tweeking, as I'll be using lot's of lists throughout my site. The "Active Widget" gizmo looks pretty good, but (a) I don't want to shell out $400+ for a table maker, and (b) I want total control over look/feel/behavior.

    The majority of my lists will be populated by my database, which brings up another question or 2. So far I'm building and populating my list (table) via PHP and echo's. This was fine the first time, but it's going to get more annoying as time goes on. What I'm thinking is that the table structure is already built (via javascript) and the backend ajax summoned PHP/sql code merely fills in the appropriate cells.

    This brings up a question that's been looming in my head. The data in the list is totally db driven, so, for example, if you re-sort the list, it does so through sql calls, and the list is repopulated. When does it make sense to do one sql call to populate the entire list, then do all your sorting and editing on the local data, then update the db when you're done. My lists range in size from a handful of rows to 3 or 4000 rows (and could grow).

    Ok... so, I guess there are 2 questions... does such a freebie list/table widget exist or should I simply build my own from scratch (and from scratch I'm thinking of using the javascript drawing lib to get the list exactly like i want it - or am i nuts?), and secondly, do I do my sorting via sql and repopulate, or keep all the data massaging on the client side and update the db when the client is done?

  • #2
    Regular Coder
    Join Date
    May 2007
    Location
    Manteca, CA
    Posts
    219
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Hmmm... 74 views on this thread but no responses. well, i think i've figured out the way to go but i have a specific question...

    for the purpose of reusability, i'm going to build my own table in javascript (using DOM/tables), with the intention of not having to write any additional html or any other code to create a customizeable table.

    the way i've been doing my db driven tables is by doing something like...

    while($row = mysql_fetch_array( $result ))
    {
    // Print out the contents of each row into a table
    $fName=$row['firstname'];
    $lName=$row['lastname'];

    echo "
    <table ...
    <tr>...
    etc, etc

    So, as most of the beginner tutorials demonstrate, you end up passing back a long string that has the entire table construct with embedded data. It works but makes for horrible reusability.

    What I'm about to do is build the table structure in javascript (as i mentioned above), and ajax the data back to the javascript code (now that i'm finally an ajax wiz), and have the javascript fill in the table.

    I'm sure I can experiment and get the answer to this but in the hopes of saving time...

    My question is... what is the best way to pass back the array of data back to the javascript. In the php code I grab the data via "$row = mysql_fetch_array( $result )" and "$colValue = $row['fld_name']". So one simplistic approach that comes to mind is simply building a string that holds the array of data. Is that the way to go? Thoughts from you experts are most appreciated.


  •  

    Posting Permissions

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