0

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'");
2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by mschroeder
0

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());
0

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());
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.