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 "&#92 +5;ίκος" ); }

In reply to Re^4: Making an automatic counter adder for all webpages by Nik
in thread Making an automatic counter adder for all webpages by Nik

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.