If i put the id on the url and click the image then all the images on the page will increment the views on the database.
So what should I do so that only the clciked image have increase views in the database.
Why do you have it in the loop along with the display of the images? You increase the $link_id on every iteration, that makes no sense at all. $link_id is supposed to be taken from the url and the query executed once:
$sql1="UPDATE wall_f SET wall_views = wall_views + 1 Where wall_id = $link_id";
If you're in one of those predicaments where cls.__private attributes just aren't enough since they can easily be accessed through inst._cls__private, and you need something a little more secure, here's ...