I'm making a page views script. I kinda need help with making the database making it +1 each view.
This is my current code:
mysql_query("UPADTE posts SET views=+1 id='$start'");
I figured out the code. =) All I had to do was do some math!
Heres the code for anyone who wants it!
$id = $row['views'];
$plus = $id + 1;
mysql_query("UPDATE posts SET views='$plus' WHERE id='$start'") or die(mysql_error());
I know you already solved this, but you can also achieve this without having to do the addition in php.
mysql_query("UPDATE posts SET views = views + 1 WHERE id='$start'") or die(mysql_error());
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.