in reply to Perl: info from database into a form(HTML)

Hi alen129,

By "different DB", do you mean a second database on the same server, or does it need to be submitted to a different server?

There are several ways to approach this problem. One "classic" way would be to have your CGI script read from the database via DBI (you've already got code for that), generate HTML (looks like you've already got some of that, I'll make a suggestion below), and when the HTML form is submitted back to the same or a different CGI script, that script can write it to the second database.

Another possible approach, which I'm suggesting because you're already using jQuery, is to have most of the code written in JavaScript as part of the HTML page, and then have the Perl CGI script not generate any HTML, but only access the databases (again via DBI), and it could speak to the script in the browser with JSON (see e.g. jQuery.ajax()).

The latter approach is the way many modern websites work, but it requires a good understanding of JavaScript. The first approach is the "classic" way of doing web forms, which doesn't necessarily require any JavaScript and therefore works in just about any browser.

To get back to your question, it sounds to me like what you're missing here is how to get the data from the database into the HTML? Here's one way:

use warnings; use strict; use CGI qw/ escapeHTML /; # this is the data you'd normally get from the DB my @cols = ( "foo", "bar", "q\"><uz" ); print qq{<table>\n<tr>\n}; for my $col (@cols) { print qq{\t<td><input type="text" value="}, escapeHTML($col), qq{"></td>\n}; }; print qq{</tr>\n</table>\n}; __END__ Output: <table> <tr> <td><input type="text" value="foo"></td> <td><input type="text" value="bar"></td> <td><input type="text" value="q&quot;&gt;&lt;uz"></td> </tr> </table>

However, there are also much better ways to generate HTML than a bunch of prints, just one example of many is Template::Toolkit, or even modern web frameworks like Dancer, Catalyst, or Mojolicious. For simple stuff I like the latter, there are some tutorials here.

Hope this helps,
-- Hauke D