Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub showfriends
- {
- #start html table
- print qq~<html>
- <head>
- <Title>My Friends</Title>
- </head>
- <body>
- <table border=1>
- <tr>
- <th>ID</th><th>Last Name</th><th>First Name</th><th>Phone Number</th><th>Email</th>
- </tr>~;
- #form SQL Select Statement
- $select = qq~select id, lname, fname, phone, email from friends~;
- #connect to MySQL and create a DB handler $dbh
- $dbh=DBI->connect($connectionInfo,$user,$passwd);
- #prepare MySQL statement and create Statement Handler $sth
- $sth=$dbh->prepare($select);
- #Execute select statement
- $sth->execute();
- #Loop through each record selected and print in html table
- while (@row=$sth->fetchrow_array())
- {
- print qq~<tr>
- <td>$row[0]</td><td>$row[1]</td><td>$row[2]</td>
- <td>$row[3]</td><td>$row[4]</td>
- </tr>~;
- }
- #close HTML table
- print qq~</table>
- </body>
- </html>~;
- $dbh->disconnect();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement