In my database in the paginas
table I have the fields pagina_1
, pagina_2
and pagina_3
representing the three pages of my site.
In these fields I'll insert the page views as below.
In my "page one" code, for example:
<?php
$result = mysql_query( "SELECT pagina_1 FROM paginas" )
or die ( mysql_error() );
$row = mysql_fetch_assoc( $result );
$visualizacoes = $row['pagina_1'];
$visualizacoes_mais = $visualizacoes + 1;
$sql = mysql_query( "UPDATE paginas SET pagina_1 ='$visualizacoes_mais' " )
or die ( mysql_error() );
...
?>
With this code I get that every time a page is accessed, views are incremented.
Is it a good way to record views for each page? I know it's a relative question, but in the background I want to know if there is another way or if it's the same: will I have to create a field for every page my site has, whether it's 10, 100 or 1000 pages?