On this case while you clicking a image in gallery which leads to the photo displaying page along with comments. So you have to pass an value to this page in URL like below
Code: Select all
<a href="phototemplate.php?photoid=1"><img src="image.jpg" /></a>
Code: Select all
$query="SELECT * FROM photo where id=".$_REQUEST['photoid']."";
Thank You