well your database will have records in, or should otherwise what are you updating?!
one of the fields would contain which url is being viewed and updated.
the url could be the whole url (http://www.yourweb.com/page.php) or just page.php
either way you need a way of finding this out from your php script so you know which record needs updating
for the complete url its $SERVER[REQUEST_URI]
and for the page its $SERVER[PHP_SELF]
$page = $_SERVER[REQUEST_URI];
or
$page = $_SERVER[PHP_SELF];
$sql = "UPDATE table set viewed=viewed+1 where page='".$page."'";
$query = mysql_query($sql);