jorvic has asked for the wisdom of the Perl Monks concerning the following question:
I'm creating a CGI that will connect to a MySQL database to read various things. It would make the code cleaner and easier (I thought) if I fetched a hash instead of an array (like usual).
^^ Doesnt print out anything. I've tried many variations of this and the most I can seem to get is a printing of hex numbers that repersent where the hash is in memory I think (whats the correct term for that?).while($info = $sth->fetchrow_hashref) { @case = keys %{info}; print @case; }
^^ Is a snippet of code I found that prints out the results of the SQL query. I thought I understood what this code was doing but since I've had no luck playing with my own I'm guessing I dont understand it like I thought.while ( my $row = $sth->fetchrow_hashref ) { print "New:\n"; foreach my $field ( keys %{ $row } ) { print "$field: $row->{ $field }\n"; }}
What I'm trying to end up having happen is my CGI script will have popup menus. I was wanting those popup menu's populated with entries from the SQL query. To make this easier I thought I would fetch a hash, dump all of the values from the hash into an array and use that array to in the popup menu.
Any advice or information anyone can spare would be wonderful.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI Fetchrow_hasref issue
by jweed (Chaplain) on Feb 21, 2004 at 17:20 UTC | |
|
Re: DBI Fetchrow_hasref issue
by jonadab (Parson) on Feb 21, 2004 at 17:24 UTC | |
|
Re: DBI Fetchrow_hasref issue
by tilly (Archbishop) on Feb 21, 2004 at 17:35 UTC | |
|
Re: DBI Fetchrow_hasref issue
by jarich (Curate) on Feb 21, 2004 at 18:21 UTC | |
|
Re: DBI Fetchrow_hasref issue
by zentara (Cardinal) on Feb 21, 2004 at 17:22 UTC | |
|
Re: DBI fetchrow_hashref issue
by cchampion (Curate) on Feb 21, 2004 at 18:40 UTC | |
|
Re: DBI fetchrow_hashref issue
by jeffa (Bishop) on Feb 22, 2004 at 05:23 UTC |