MySQL Forums
Forum List  »  Perl

How to display returned rows in HTML page??
Posted by: Naveen Gupta
Date: April 28, 2005 11:08PM

hi,
i'v just started learning perl and have a project which requires mysql in the backend. To start with i need to display all the rows of a table (select* from table) in an html page and the scripting needs ot be in perl. I've managed to create a perl script which looks like this:

#!/usr/bin/perl

use DBI qw(:sql_types);

my ($databaseName, $host, $databaseUser, $databasePw, $dbh);
my ($stmt, $sth, @newRow);
my ($counter);

$databaseName="@@@@";
$host="@@@@@";
$databaseUser="user";
$databasePw="password";

my $dbh = DBI->connect("DBI:mysql:database=$databaseName:host=$host", $databaseUser, $databasePw) or die "Can't connect to database:$DBI::errstr\n";
print("Successfully connected to MySql Database.");

$stmt = "SELECT * FROM table";

$sth = $dbh->prepare($stmt) || die "prepare: $$stmt: $DBI::errstr";
$sth->execute || die "execute: $$stmt: $DBI::errstr";

@record = $sth->fetchrow();

$counter = $record[0];

$sth->finish();
$dbh->disconnect();

But the problem is how to convert it into a cgi script to be placed in a web server, so that after clicking a button for example, the sql query in the code is displayed in the html page..i am clueless about th html code to be written
Please help
naveen

Options: ReplyQuote


Subject
Written By
Posted
How to display returned rows in HTML page??
April 28, 2005 11:08PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.