Somethign about hashes

N

Nikos

while( $row = $sth->fetchrow_hashref )
{
print table( {class=>'user_form'},

Tr(
td( {-width=>'25%'}, {class=>'name'}, $row->{name} ),
td( {-width=>'50%'}, {class=>'email'}, $row->{email} ),
td( {-width=>'25%'}, {class=>'date'}, $row->{date} )
),

{snip more code]


I use the above code when i retrives rows of information from my mysql
database but in the print output a see soemthing like hash(0x0A8B)and
after that the data when what i only want is the actual data itself.

The code is correct but why does those hashed appear?
 
P

Peter Wyzl

: while( $row = $sth->fetchrow_hashref )
: {
: print table( {class=>'user_form'},
:
: Tr(
: td( {-width=>'25%'}, {class=>'name'}, $row->{name} ),
: td( {-width=>'50%'}, {class=>'email'}, $row->{email} ),
: td( {-width=>'25%'}, {class=>'date'}, $row->{date} )
: ),
:
: {snip more code]
:
:
: I use the above code when i retrives rows of information from my mysql
: database but in the print output a see soemthing like hash(0x0A8B)and
: after that the data when what i only want is the actual data itself.
:
: The code is correct but why does those hashed appear?


The output code is wrong. Therefore posting the input code is not much
help.

P
 
G

Greg Bacon

: while( $row = $sth->fetchrow_hashref )
: {
: print table( {class=>'user_form'},
:
: Tr(
: td( {-width=>'25%'}, {class=>'name'}, $row->{name} ),
: td( {-width=>'50%'}, {class=>'email'}, $row->{email} ),
: td( {-width=>'25%'}, {class=>'date'}, $row->{date} )
: ),
:
: {snip more code]
:
: I use the above code when i retrives rows of information from my mysql
: database but in the print output a see soemthing like hash(0x0A8B)and
: after that the data when what i only want is the actual data itself.
:
: The code is correct but why does those hashed appear?

If the code were correct, the hashes wouldn't appear.

The problem with your code is that it has the class attribute values in
separate hashes, but they're supposed to be in a single hash per element
as in the following code:

#! /usr/local/bin/perl

use warnings;
use strict;

package FakeSth;

sub new { bless {} => shift }

{
my $counter;
sub fetchrow_hashref {
return unless $counter++ < 3;

return {
name => "name" . $counter,
email => "email" . $counter,
date => "date" . $counter,
};
}
}

package main;

use CGI qw/ :html /;

my $sth = new FakeSth;

my $row;
while( $row = $sth->fetchrow_hashref )
{
print table( {class=>'user_form'},

Tr(
td( {-width=>'25%', class=>'name'}, $row->{name} ),
td( {-width=>'50%', class=>'email'}, $row->{email} ),
td( {-width=>'25%', class=>'date'}, $row->{date} ),
),
);
}

Hope this helps,
Greg
 
N

Nikos

Greg said:
The problem with your code is that it has the class attribute values in
separate hashes, but they're supposed to be in a single hash per element
as in the following code:


Yes that was the mistake. thank you for pinting this out. :)
 
N

Nikos

Maybe you can help me with this too:


print span( {class=>'tip'}, "Some Greek Text!" );

========================
span.tip {
text-align: center;
font: 20px comic;
color: lime;
}
========================

Although i have specified a style and iam using it the print the text
aint being centered.

What am i doing wrong?
 
G

Gunnar Hjalmarsson

Nikos said:
print span( {class=>'tip'}, "Some Greek Text!" );

========================
span.tip {
text-align: center;
font: 20px comic;
color: lime;
}
========================

Although i have specified a style and iam using it the print the text
aint being centered.

What am i doing wrong?

You are using CSS while refusing to study the docs for it.
 
N

Nikos

A. Sinan Unur said:
You are making false statements again:

<URL: http://groups-beta.google.com/group...ce89b2db30d/0bd488c7cab7d760#0bd488c7cab7d760>

It seems like you got useful answers. The fact that you don't
like them, and you want others to do your work does not change
that fact.

Now, try to remember what we call people who insist on making
false statements?

Ah, so they did answer there.....
Thats nice to hear, iw aited 2 days but i didnt got any response and
today morning i unsubscribed from alt.html considering that after what
grg said they will never anser.

Now with the url you pointed to me i just saw their new responses.

Sorry about that but once again iam i am a vivtim of circumstances....
 
N

Nikos

Tad said:
That's too bad, but it does not change a CSS question
into a Perl question.

PLEASE STOP ABUSING OUR NEWSGROUP!

Its not completely irrelevant with Perl since it embeds the use of cgi.pm
 
C

Chris Mattern

Nikos said:
Its not completely irrelevant with Perl since it embeds the use of cgi.pm
Tell me, if you drove your car to the supermarket and they were out
of milk, would you regard this as a matter to take up with your
mechanic? After all, it happened while you were on a trip with
your car!

--
Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
 
N

Nikos

Chris said:
Tell me, if you drove your car to the supermarket and they were out
of milk, would you regard this as a matter to take up with your
mechanic? After all, it happened while you were on a trip with
your car!

lol! :)

ok, but it wouldnt be much of a trouble if you helped me a little on the
styling since little details are confusing me, would it?

if yes, the ignore my question.
 
T

Tintin

Nikos said:
Ah, so they did answer there.....
Thats nice to hear, iw aited 2 days but i didnt got any response and today
morning i unsubscribed from alt.html considering that after what grg said
they will never anser.

Now with the url you pointed to me i just saw their new responses.

Sorry about that but once again iam i am a vivtim of circumstances....

More a victim of your own impatience and lazyness.
 
T

Tad McClellan

but once again iam i am a vivtim of circumstances....


Once, twice, thrice maybe.

But you've done it DOZENS of times!

The root of the problem here is that you do not respect
the other people on this newsgroup.
 
T

Tad McClellan

Nikos said:
lol! :)

ok, but it wouldnt be much of a trouble if you helped me a little on the
styling since little details are confusing me, would it?


But then someone else will see that they can get CSS and web server
and MySQL problems answered here, and they will post _their_ questions.

If we let you throw trash in our park without complaint, then we
will end up with LOTS more trash in the park.

We like our park. We don't like you trashing it, so please stop doing that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top