Re: Looping almost the same repetitive lines



Nikos wrote:


$st = $db->prepare( "SELECT * FROM counter" );
you need to check the return value of this.

What happens when you execute this statement directly within the db
console? (mysql in this case) Do you get any results?

$st->execute();
and checj the return value of this.

$row = $st->fetchrow_hashref;

@tableRows = ();

while( $item = $st->fetchrow_hashref()) {
    push @tableRows, $item;
};

What happens when you use Data::Dumper to display @tablerows? Is it empty? If so, you have an issue with your query.




print table( {class=>'info'},
    map {
         Tr(
            td( submit( -name=>'game', -value=>$_->{name} )),
            td( $_->{text} ),
            td( $_->{name} )
            )
        } @tableRows
);

Whne i perl -c games.pl it says games.pl syntax OK from command line
Fine: it compiles. That doesn't tell us a lot. What happens when you *run* it?

when i view it from the broswer the only thing it displays is some other text above that code and nothing more. i t not evne designs the table.
You need to learn to partition your problem. What the browser displays is academic at this point; first of all you need to ascertain what the script is doing at what it outputs. You don't seem to know how to debug your programs.

You *need* to use strict. You *need* to use warnings. You *need* to use my. If you don't understand why, you need to read some more.

Mark
.