Hi all,
Currently i have a CGI web page which prints a mySQL search query to the web. However, i want to incorporate a drop down menu which will allow the user to refine the results. I can do this by directing a form to a new script, but i want to recycle the default page.
I guess this would use the GET method from the url. But how is this achieved?
If anyone could suggest a useful tutorial or point me in the right direction that would be great!
print "Content-type: text/html\n\n";
use DBI;
# database information
# make connection to database
$dbh = DBI->connect($connectionInfo,$userid,$passwd);
# prepare and execute query
$query = "SELECT * FROM employees ORDER BY lastName, firstName";
$sth = $dbh->prepare($query);
$sth->execute();
# assign fields to variables
$sth->bind_columns(undef, \$employeeID, \$firstName, \$lastName);
print "Employees in the inventory database:<p>";
print "<form action=\"displayResults.pl\" method=post>";
print "<select name=employeeID><option value=\"\">Select an employee</
+option>";
# output employee list to browser as drop-down listings
while($sth->fetch()) {
print "<option value=$employeeID>$firstName $lastName</option>";
}
print "</select><input type=submit name=submit value=submit></form>";
$sth->finish();
#disconnect from database
$dbh->disconnect;
Thanks
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.