Forum Moderators: coopster
Edit: I just found out that I had a typo. But the question remains: is this the "right" way?
while ($row = mysql_fetch_array($sql_whatever))
{
if ($row[type] == "Something")
{
echo ''.$row[pretext].'<A HREF="/?a='.$row[id].'">'.$row[anchor].$row[tracker].'</A> <BR><BR>';
$sql_views="UPDATE aff SET views = views + 1 WHERE id = '$row[id]'";
if(!mysql_query($sql_views)) die(mysql_error());
}
}
Not quite sure how to though ;-)
hughie
For example:
$where = "widget_type='BLUE'";$sql = "SELECT * FROM aff WHERE $where";
// execute $sql and display results as per your code, and then:
$sql = "UPDATE aff SET views = views + 1 WHERE $where";
// execute update SQL
This way, you're only doing 2 hits on the database instead of (n+1) where n is the number of products returned.