Good afternoon. I have some code that displays data from a MySQL databason on screen. I want to modify this code to not only display the data, but add a edit button at the end of each displayed line that will allow a user to select it and be directed to another page that will allow them to modify the row of data in the database. So far I have been unsuccessful at adding the button and getting it to open a new page. Can anyone help me on correct placement of this button, and how I go about opening a new update page? I have removed all code I have been working with to get this done and am back at square one. This is the current code that will allow the display on screen:
#!perl use DBI; use CGI; print "Content-Type: text/html\n\n"; $head = <<'HEAD'; <html> <head> <title>Branch Inventory Lookup</title> </head> <body style="font-size:11px;font-family:tahoma;background:#F9F9DD;padd +ing:0;margin:0;"> HEAD $tail = <<'TAIL'; </body> </html> TAIL $body = <<'BODY'; <div style="padding-left:20px;padding-top:10px;background:#F9F9DD;"><h +1><font color="#006600"> Branch Inventory Query</font></h1>div> <div style="font-size:18px;letter-spacing:5px;padding-top:15px;text-al +ign:center;background:#F9F9DD;width:100%;"> <form action="http://hmDir/cgi-bin/Inventory.pl" method="get"> <select style="font-size:15px;" name="field"> <option value="Branch">Branch</option> <option value="AssetTag">Asset Tag</option> <option value="SerialNumber">Serial Number</option> <option value="Status">Status</option> <option value="AssetType">Asset Type</option> </select> <select name="likeEquals" style="font-size:15px;"> <option value="=">=</option> <option value="LIKE">LIKE</option> </select> <input style="font-size:15px;" type="text" name="searchTerm"/> <input style="font-size:15px;" type="submit" name="search" value=" +Search"/> </form> </div> <div style="font-size:18px;letter-spacing:5px;padding-top:15px;padding +-right:20px;text-align:right;background:#F9F9DD;width:100%;"> <form method="get"> <input type="button" value="Print" onclick="window.print()" /> </form> </div> BODY $results = <<'RESULTS'; <div style="padding:5px;position:absolute;top:275px;height:100px;width +:100%;background:#F9F9DD;"> <table cellspacing="0" cellpadding="3" style="padding:5px;font-size:11 +px;border:1px black solid;" bgcolor="#EEEEEE" width="100%"> RESULTS $i = 0; $c = new CGI(); $searchTerm = $c->param("searchTerm"); $likeEquals = $c->param("likeEquals"); $field = $c->param("field"); $searchTerm =~ s/'/\\'/; $likeEquals =~ s/'/\\'/; $field =~ s/'/\\'/; if($searchTerm eq "") { $searchTerm = "void"; } $h = DBI->connect("dbi:mysql:inventory:localhost","ID","PW") or die("c +ouldnt connect to database"); $query = "SELECT SerialNumber, AssetTag, AssetType, Branch, Status, Co +mments FROM assets WHERE $field $likeEquals ? ORDER BY AssetType"; $q = $h->prepare($query); $rows = $q->execute($searchTerm); %columns = ( SerialNumber => "Serial Number", AssetTag => "Asset Tag", AssetType => "Asset Type", Branch => "Branch", Status => "Status", Comments => "Comments", ); if($rows > 0) { $results .= "<tr><td colspan='6'>Your search for <b>$searchTerm</b> in + <b>$columns{$field}</b> returned <b>$rows</b> result(s).</td></tr>"; $results .= "<tr style='background:black;color:white;font-weight:900;' +>"; foreach $field (@{$q->{NAME}}) { $results .= "<td width='50'>$columns{$field}</td>"; } $results .= "</tr>"; if($c->param("searchTerm")) { while ($row = $q->fetchrow_hashref) { if($i % 2 == 0) { $results .= "<tr style='height:30px;border-bottom:1px;'><t +d>$row->{SerialNumber}</td><td>$row->{AssetTag}</td><td>$row->{AssetT +ype}</td><td>$row->{Branch}</td><td>$row->{Status}</td><td>$row->{Com +ments}</td></tr>"; } else { $results .= "<tr style='height:30px;border-bottom:1px;back +ground:#DDD;'><td>$row->{SerialNumber}</td><td>$row->{AssetTag}</td>< +td>$row->{AssetType}</td><td>$row->{Branch}</td><td>$row->{Status}</t +d><td>$row->{Comments}</td></tr>"; } $i++; } } } else { $results .= "<b>No results matched your Inventory query.</b>"; } $h->disconnect(); $results .= <<'RESULTS'; </table> </div> RESULTS print $head; print $body; print $results; print $tail;
Thanks in advance for any help I may receive on how to add buttons after each displayed line of data from the query results.

In reply to Adding command button to selevt a value by jaacmmason

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.