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";