I am displaying records from a DB using HTML:Template:
my $rows = $dbh->selectall_arrayref($SQL,{Columns =>{}}) ; $template->param(ROWS => $rows || []);
Fields that can be modified are displayed as text boxes. In addition, next to each row, an update button is also displayed. So a user could modify the value in a text box and click the Update button for that row. eg:
<!-- TMPL_LOOP NAME=ROWS --> <tr> . . . <td> <input type="text" value = "<!-- TMPL_VAR NAME=Detail -->" size="43" n +ame="Detail"> </td> <td> <input type="submit" value="Update"> </td> </tr> <!-- /TMPL_LOOP -->
If 5 rows are displayed, there would be 5 Update buttons-one for each row. What is happening is that the Update button works only for the first row. How can I associate each Update button with the corressponding row? Here's the Perl script called when the Update button is clicked(scaled down version):
$ticket = $query->param('TicketNo'); $detail = $query->param('Detail'); . . . my $temp1 = "UPDATE TSIssuesTable "; my $temp2 = "SET Detail = ?"; my $temp3 = "WHERE "; my $temp4 = "TicketNo = $ticket"; $SQL = $temp1.$temp2.$temp3.$temp4; $sth1 = $dbh->prepare( $SQL ); $sth1->execute($details); ...
Thanks!

In reply to Logical question-to upate DB records by thisisperl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.