Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use DBI;
- use DBD::mysql;
- print "content-type: text/html \n\n";
- #Config vars
- $host = "localhost";
- $database = "<your database>";
- $tablename = "employee";
- $user = "<your user id>";
- $pw = "student";
- #DATA SOURCE NAME
- $dsn = "dbi:mysql:$database:localhost:3306";
- #PERL DBI Connect
- $connect = DBI->connect($dsn,$user,$pw)
- or die "Unable to connect $DBI:errstr\n";
- $query = "Select * from employee";
- $query_handle = $connect->prepare($query);
- #Execute the query
- $query_handle->execute();
- #BIND Table columns to variables
- $query_handle->bind_columns(\$id,\$lname,\$fname,\$job);
- #!/usr/bin/perl
- use DBI;
- use DBD::mysql;
- print "content-type: text/html \n\n";
- #Config vars
- $host = "localhost";
- $database = "bstudent";
- $tablename = "employee";
- $user = "bstudent";
- $pw = "student";
- #DATA SOURCE NAME
- $dsn = "dbi:mysql:$database:localhost:3306";
- #PERL DBI Connect
- $connect = DBI->connect($dsn,$user,$pw)
- or die "Unable to connect $DBI:errstr\n";
- $query = "Select * from employee";
- $query_handle = $connect->prepare($query);
- #Execute the query
- $query_handle->execute();
- #BIND Table columns to variables
- $query_handle->bind_columns(\$id,\$lname,\$fname,\$job);
- print "<html><title>Show Employees</title>";
- print "<body>";
- print "<h1>Employee List</h1>";
- print "<table>";
- #LOOP through results
- while($query_handle->fetch()) {
- print "<tr>";
- print "<td>$id</td><td>$lname</td><td>$fname</td><td>$job</td>";
- print "</tr>";
- }
- print "</table>";
- print "</body></html>";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement