[PHP]<?php
$query = "SELECT viewed FROM $j where id='$file'";
$result = mysql_query($qu ery);
while($row = mysql_fetch_arr ay($result, MYSQL_ASSOC))
{
$viewed = $row['viewed'];
}
if ($viewed == '0')
{
$addone = '1';
}
else
{
$addone = $viewed + 1;
}
mysql_query("UP DATE $j SET viewed='$addone ' WHERE id=$file");
?>[/PHP]
I want to know how many times an ad is viewed on my website. So I want the number stored in the row - $viewed - to increase by one each time the ad it's associated with is viewed. The default value is "0" so when the ad is viewed for the first time "0" is changed to "1" and then it increases by one each time it's viewed.
I just want to make sure that I have this right, because I wonder if sometimes the number isn't being increased by 2, 3 or more.
$query = "SELECT viewed FROM $j where id='$file'";
$result = mysql_query($qu ery);
while($row = mysql_fetch_arr ay($result, MYSQL_ASSOC))
{
$viewed = $row['viewed'];
}
if ($viewed == '0')
{
$addone = '1';
}
else
{
$addone = $viewed + 1;
}
mysql_query("UP DATE $j SET viewed='$addone ' WHERE id=$file");
?>[/PHP]
I want to know how many times an ad is viewed on my website. So I want the number stored in the row - $viewed - to increase by one each time the ad it's associated with is viewed. The default value is "0" so when the ad is viewed for the first time "0" is changed to "1" and then it increases by one each time it's viewed.
I just want to make sure that I have this right, because I wonder if sometimes the number isn't being increased by 2, 3 or more.
Comment