Can you select and update in the same query? I\'m trying to count views to create a top blog posts by views for my sidebar.
$sql = mysql_query(\"SELECT * FRO
No, you cannot do that, but there is nothing wrong with doing two queries.
mysql_query("UPDATE pages SET views=views+1 WHERE ID=$id");
$sql = mysql_query("SELECT * FROM articles WHERE id=$id");
Also, if id
is the primary key you don't have to do LIMIT 1
here, id
is unique, therefore it will always have only one result matching your condition.