$sel_cate = mysql_query("SELECT * from category where status='1' and id in (SELECT category_name FROM gallery_images where type='Photos' and image!='' and status='1' order by id desc)order by id desc limit $offset,$entries_per_page");
if(mysql_num_rows($sel_cate)>0)
{
?>
$i=0;
while($cate_details = mysql_fetch_assoc($sel_cate))
{
$i=$i+1;
$cate_id = $cate_details['id'];
$cate_name = $cate_details['category_name'];
$sel_image = mysql_query("select * from gallery_images where category_name='$cate_id' and type='Photos' and image!='' and status='1' order by id desc limit 1");
$tot_imgs = mysql_num_rows($sel_image);
$img_details = mysql_fetch_assoc($sel_image);
//echo $img_details['Image'];
if($tot_imgs != '0')
{
if($img_details['image']!='')
{
$large_image=eregi_replace('gallery-images/','',$img_details['image']);
if(file_exists('uploads/gallery-images/400-'.$large_image))
{
$thumbnail_image='uploads/gallery-images/400-'.$large_image;
}
else
{
$thumbnail_image='uploads/gallery-images/'.$large_image;
}
}
}
?>
} ?>
} ?>
if($num_rows ==0) { echo ' No Data Found!!!';} if($num_rows >9) { echo $pagination;} ?>