I know it can be done this way:
mysql_query(" UPDATE products SET page_views = $page_views + 1 WHERE id = '3' ");
But I don't want to do a select query and then a while loop in order to first get the value of the page_views row and store that value in a variable called $page_views in order to do the update query.
Are there any SQL ways of getting the value of the field and updating it by 1 in the same query? I tried this but it didn't work:
mysql_query(" UPDATE products SET page_views = page_views + 1 WHERE id = '3' ");
IN your second query i think page_views + 1 is not working together so make it this way
mysql_query(" UPDATE products SET page_views = (page_views + 1) WHERE id = '3' ");