Is more straightforward this way except the fact that each time i hit a game sumbit button all the counters are being increased, instead of the proper clicked one! and except that the execution of the code never enetes this section:#=======================LOADING THE .TXT TO THE DATABASE============== +========== # get a list of all gamenames in the table my $select = $dbh->prepare( "SELECT gamename FROM games"); $select->execute() || die $dbh->errstr; # convert to hash for quick lookup in file-reading loop my %gamename_hash = (); while (my @gn = $select->fetchrow_array) { $gamename_hash{$gn[0]} = 1; } open (FILE, "<../data/games/descriptions.txt") or die $!; while (<FILE>) { chomp; next unless (length); # Skip if blank line my ($name, $desc) = split(/\t/, $_, 2); if ($gamename_hash{$name}) { # The gamename is already in the table. Increment the counter. $dbh->do( "UPDATE games SET gamecounter=gamecounter+1 WHERE (g +amename=?)", undef, $name) || die $dbh->errstr; } else { # The gamename is not in the table. Create a new record. $dbh->do( "INSERT INTO games (gamename, gamedesc, gamecounter) + VALUES (?,?,?)", undef, ($name, $desc, 0) ) || die $dbh->errstr; } } close (FILE);
td( {-width=>'20%'}, submit( -name=>'gamename', -value=>$row->{gamename} )), is inside the formif( param('gamename') ) { $dbh->do( "UPDATE games SET gamecounter=gamecounter+1 WHERE gamena +me='$gamename'" ); $dbh->do( "UPDATE guestlog SET passage='$gamename' WHERE host='$ho +st'" ); $sth = $dbh->prepare( "SELECT * FROM games WHERE gamename=?" ); $sth->execute( $gamename ); $row = $sth->fetchrow_hashref; print span( {class=>'lime'}, "Είσαι ο $row->{gamecounter} ος πο +υ κατεβάζει το $row->{gamename} !!" ), br; print span( {class=>'yellow'}, "Ελπίζω να σου αρέσει και να σου φ +ανεί χρήσιμο!" ); print p( {-align=>'center'}, a( {href=>'index.pl'}, img {src=>'. +./data/images/back.gif'} )); print "<script language='Javascript'>location.href=/data/games/$ga +mename.rar</script>"; }
In reply to Games.pl again by Nik
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |