Yes indeed this is very clear and better.
But in order to increase a counter for a specific page or create it first and then populate it, the script must know which webpage just loaded for example page_5.html and extract just the filename without the dot and extension.
How to do this? The best i can do is this:
$pagename = "something that tells me what si the name of the currnt sc
+ript running, just its filename";
if ( $pagename is an already actual field inside table 'counter' then
+)
{
$select = $db->prepare( "SELECT pagename, pagecounter FROM counter
+s" );
$select->execute;
}
else
{
$select = $db->prepare( "INSERT INTO counters (pagename, pagecount
+er) VALUES (?, ?)" );
$select->execute( $pagename, 1 );
my $pagecounter;
while( $row = $select->fetchrow_hashref )
{
$pagecounter += $row->{pagecounter} unless ( $row->{host} eq "\
+5;ίκος" );
}
|