Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I am hoping some one can help me here...
I basically want to be able to output the contents of a mysql table:
--------------------------------------------------------- |Name | Address | Tel | Email | --------------------------------------------------------- | Bob | 1 London Road | 00000000000 | bob@london.co.uk | --------------------------------------------------------- | Tony | 10 Downing St | 99999999999 | tony@no10.co.uk | ---------------------------------------------------------
like this:
Name: Bob Address: 1 London Road Tel: 00000000000 Email: bob@london.co.uk Name: Tony Address : 10 Downing St Tel: 99999999999 Email: tony@no10.co.uk
Here's my current code:
use DBI; # my $sql = "SELECT * FROM win32_processor"; my $sql = "SHOW FIELDS FROM win32_processor"; # Connect to the database. if (! saracen_open_database_connection ( \$dbh, $program_config{saracen_database}, $program_config{saracen_admin_login}, $program_config{saracen_admin_pass} ) ) { # Indicate that a problem occured. return 0; } if (! saracen_execute_query(\$dbh, \$sth, $sql)) { return 0; } #output database results while (@row = $sth->fetchrow_array) { print "@row\n" }
Im afraid my perl or mysql knowledge isn't extensive enough to solve this problem. I can get a table of fields, and I can get a table of values, I just cant seem to put them together!
Cheers, Marcel
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl/MySQL
by FitTrend (Pilgrim) on Feb 12, 2005 at 20:31 UTC | |
|
Re: Perl/MySQL
by matija (Priest) on Feb 12, 2005 at 20:34 UTC | |
by Anonymous Monk on Feb 15, 2005 at 14:12 UTC | |
|
Re: Perl/MySQL
by hubb0r (Pilgrim) on Feb 12, 2005 at 20:41 UTC | |
|
Re: Perl/MySQL
by mr_jpeg (Beadle) on Feb 13, 2005 at 00:36 UTC |