http://qs1969.pair.com?node_id=658635

Nik has asked for the wisdom of the Perl Monks concerning the following question:

The following code connect to my db, graps the counter field value which holds an integer that represents the total amount of hits in index.pl
my $db = ( $ENV{'SERVER_NAME'} !~ /varsa/ ) ? DBI->connect('DBI:mysql:pneumatika;localhost', 'root', '***** +**', {RaiseError=>1}) : DBI->connect('DBI:mysql:18177_pneumatika;fdb1.runhosting.com' +, '18177_pneumatika', '*****', {RaiseError=>1}); $select = $db->prepare( "SELECT counter, host FROM guestlog" ); $select->execute; my $pagecounter; while( $row = $select->fetchrow_hashref ) { $pagecounter += $row->{counter} unless ($row->{host} eq "varsa); }
What must be add to this code that is able to save each unique webpage counter at a specific mysql table field adding 1 every time and also do this for every new page i create because the number of the pages aren't fixed plz post it here.

The code also has to be able to modify mysql table 'guestlog' and add a new table field every time a new page is loaded that doesnt have a corresponding counter by means of table field named as the page itself holding an integer value.

For example if a user opens index.html then connect to mysql and to table counter, find index filed add 1 to it!

if a page named hello.html its loades try to add 1 to its table filed too if it does not exist, alter the table structure by adding 1 more field with the same name of the webpage and then add 1 too.

For example it the name is hello.html then the corresponing table filed has to be 'hello' with an integer value of one.

That way one can use the code in every new webpage he creates without dropping and creating a bigger mysql table.

is this possible?