in reply to Re: muli-records db update using cgi
in thread multi-record db update using cgi

It is an oracle database that I access throught DBI and DBD::oracle.
What I am trying to do is retrieve multiple records from the database for updating. I want the existing values in the database to be the default values in the respective textfields (and blank if the db value is null). I want to display the records in a table format so that each row is a different record, and each column is an attribute in the database.
The database contains (for example) the following fields: cd_vol_num, ship_date, tracking_num, notes.
If the user wants to update the notes of 10 cd's I want the form to print a table that has 10 rows and 4 columns.
The cd_vol_num is static so it is just text. The other fields can be updated so I want them to appear as textfields. I was trying to do this using an array of hashes.
If the 4th cd in the series already has notes I want those be the default value for that cell. So that they appear when the page is rendered. This way the user can append to the notes or remove the previous note. I need the form to only have one submit button so that when pressed all the fields will be updated in the database

Thanks for taking a look at this.
JLD
  • Comment on Re: Re: muli-records db update using cgi

Replies are listed 'Best First'.
Re: Re: Re: muli-records db update using cgi
by neniro (Priest) on Apr 18, 2004 at 10:24 UTC
    I suggest you to use HTML::Template and build your editable table like this (untested):
    <form> <TMPL_LOOP NAME=entries> <table id="CD" class="default"> <tr class="grey"> <td class="small">ID:</td> <td><TMPL_VAR NAME=id></td> <td class="small">Title:</td> <td> <input type="Text" name="title" value="<TMPL_VAR NAME=title>" /> </td> <td class="small">Comment:</td> <td> <input type="Text" name="comment" value="<TMPL_VAR NAME=comment> +" /> </td> </tr> </table> <br /> </TMPL_LOOP> <input type="Submit" name="Update" value="Update"> <input type="reset"> </form>
    If your script is called with an action 'find', you query your database and fill the table. If the action is 'update' you use the params and update-query the db.
    neniro
Re: Re: Re: muli-records db update using cgi
by matija (Priest) on Apr 18, 2004 at 10:31 UTC
    Note that while your project will have no trouble with 10 CDs, it will become unwieldly with 100 CDs, and completely useless with 500.

    You need to think of ways to limit the page size (by displaying only some of the CDs at the same time). You might find Data::Page helpfull in this regard...