<?php
	include("conn.php");
        $pgno=0;
	$pgsize=9;
	if(isset($_GET['pgno']))
	{
		$pgno=$_GET['pgno'];
	}
	$rs=mysql_query("select * from gallery order by desc1",$ln);
	if(isset($_GET['search']))
	{
		$ch=$_GET['search'];
		if($ch=="All")
		{
			$rs=mysql_query("select * from gallery order by desc1",$ln);
		}
		else
		{
			$rs=mysql_query("select * from gallery where name like '$ch%' order by desc1",$ln);
		}
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="EN" lang="EN" dir="ltr">
<head>
<title>Dr. Ravindra Patil | Gallery</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="imagetoolbar" content="no" />
<link rel="stylesheet" href="styles/layout.css" type="text/css" />
<link href="css/GalleryStyles.css" rel="stylesheet" type="text/css" />
</head>
<body id="top">
<?php include('header.php');?>
<div class="wrapper row2">
  <div class="rnd">
    <!-- ###### -->
    <div id="topnav">
      <ul>
        <li ><a style="outline:none;text-decoration:none;" href="index.php">Home</a></li>
        <li><a style="outline:none;text-decoration:none;" href="About.php">About Ravindra Patil</a></li>
	<li><a style="outline:none;text-decoration:none;" href="event.php">Events</a></li>
        <li><a style="outline:none;text-decoration:none;" href="news.php">News</a></li>
        <li><a style="outline:none;text-decoration:none;" href="media.php">Media</a></li>
        <li class="active"><a style="outline:none;text-decoration:none;" href="gallery.php">Photo Gallery</a></li>
        <li><a style="outline:none;text-decoration:none;" href="video.php">Video Gallery</a></li>
		<li class="last"><a style="outline:none;text-decoration:none;" href="contact.php">Contact Me</a></li>
      </ul>
    </div>
    <!-- ###### -->
  </div>
</div>
<!-- ####################################################################################################### -->
<div class="wrapper row3">
      <!-- ####################################################################################################### -->
	<div id="gallery" class="clear">
	  <div class="rnd">
		<!-- content begins -->
	<?php
	$i=0;
	$arrID=array();
	$arrTitle=array();
	$arrgallery=array();
	$arrDesc=array();
	while($row=mysql_fetch_row($rs))
	{
		$arrID[$i]=$row[0];
		$arrTitle[$i]=$row[1];
		$arrgallery[$i]=$row[4];
		$arrDesc[$i]=$row[2];
		$arrDate[$i]=$row[3];
		$i=$i+1;
	}	
	?>
		<div style="margin-left:150px">		
			<a class="gal_alfa" href="gallery.php?search=All">All</a>
			<?php 
			for($j=0;$j<=25;$j++)
			{
			?>
			<a class="gal_alfa" href="gallery.php?search=<?php echo chr($j+65);?>"><?php echo chr($j+65);?></a>
			<?php
			}
			?>
		</div>
		<br />
		<?php 
		$pagerow=0;
		if(isset($_GET['pgno']))
		{
			$pagerow=$_GET['pgno'];
			if($pagerow == 1)
				$pagerow=0;
			else
				$pagerow=9*($pagerow-1);
		}
		else
		{
			$pagerow=0;
		}
		?>
    	<div class="row">
			<?php 
			if((0 + $pagerow)<count($arrTitle) )
			{
			?>
			<div class="box_img2"">
				<h1>&nbsp;&nbsp;<?php echo $arrTitle[0 + $pagerow]; ?></h1>
				<h1>&nbsp;&nbsp;Date : <?php echo $arrDate[0+$pagerow];?></h1>
				 <a href="gallery/gallerydetails.php?gallery=<?php echo $arrID[0 + $pagerow]; ?>">
					<img class="g_size" src="gallery/galleryimages/<?php echo $arrgallery[0 + $pagerow];?>"/>
				</a>
			</div>
			<?php
			}
			?>
			
			
			 <div class="box_razd"></div>
			<?php 
			if((1 + $pagerow)<count($arrTitle) )
			{
			?>
			<div class="box_img2">
				<h1>&nbsp;&nbsp;<?php echo $arrTitle[1 + $pagerow]; ?></h1>
				<h1>&nbsp;&nbsp;Date : <?php echo $arrDate[1+$pagerow];?></h1>
				<a href="gallery/gallerydetails.php?gallery=<?php echo $arrID[1 + $pagerow]; ?>" >
				<img class="g_size" src="gallery/galleryimages/<?php echo $arrgallery[1 + $pagerow]; ?>"/></a>
			</div>
			<?php
			}
			?>
            <div class="box_razd"></div>
            <?php 
			if((2 + $pagerow)<count($arrTitle) )
			{
			?>  
			<div class="box_img2">
				<h1>&nbsp;&nbsp;<?php echo $arrTitle[2 + $pagerow]; ?></h1>
				<h1>&nbsp;&nbsp;Date : <?php echo $arrDate[2+$pagerow];?></h1>
				<a href="gallery/gallerydetails.php?gallery=<?php echo $arrID[2 + $pagerow]; ?>" >
				<img class="g_size" src="gallery/galleryimages/<?php echo $arrgallery[2 + $pagerow]; ?>"/></a>
				</div>
			</div>
			<?php
			}
			?>
		</div>
        <!--2nd Row -->
		<div class="row">
			<?php 
			if((3 + $pagerow)<count($arrTitle) )
			{
			?>
			<div class="box_img2">
				<h1>&nbsp;&nbsp;<?php echo $arrTitle[3 + $pagerow]; ?></h1>
								<h1>&nbsp;&nbsp;Date : <?php echo $arrDate[3+$pagerow];?></h1>
				<a href="gallery/gallerydetails.php?gallery=<?php echo $arrID[3 + $pagerow]; ?>" >
				<img class="g_size" src="gallery/galleryimages/<?php echo $arrgallery[3 + $pagerow]; ?>" /></a>
			</div>
			<?php
			}
			?>
            <div class="box_razd"></div>
            <?php 
			if((4 + $pagerow)<count($arrTitle) )
			{
			?>
			<div class="box_img2">
				<h1>&nbsp;&nbsp;<?php echo $arrTitle[4 + $pagerow]; ?></h1>
				<h1>&nbsp;&nbsp;Date : <?php echo $arrDate[4+$pagerow];?></h1>
				<a href="gallery/gallerydetails.php?gallery=<?php echo $arrID[4 + $pagerow]; ?>" >
				<img class="g_size" src="gallery/galleryimages/<?php echo $arrgallery[4 + $pagerow]; ?>"/></a>
			</div>
			<?php
			}
			?>
			<div class="box_razd"></div>
			<?php 
			if((5 + $pagerow)<count($arrTitle) )
			{
			?>          
			<div class="box_img2">
				<h1>&nbsp;&nbsp;<?php echo $arrTitle[5 + $pagerow]; ?></h1>
				<h1>&nbsp;&nbsp;Date : <?php echo $arrDate[5+$pagerow];?></h1>
				<a href="gallery/gallerydetails.php?gallery=<?php echo $arrID[5 + $pagerow]; ?>" >
				<img class="g_size" src="gallery/galleryimages/<?php echo $arrgallery[5 + $pagerow]; ?>"/></a>
			</div>
			<?php
			}
			?>
		</div>
		
		<!--3rd Row -->
				
		<div class="row">
			<?php
			if((6 + $pagerow)<count($arrTitle) )
			{
			?>
			<div class="box_img2">
				<h1>&nbsp;&nbsp;<?php echo $arrTitle[6 + $pagerow]; ?></h1>
				<h1>&nbsp;&nbsp;Date : <?php echo $arrDate[6+$pagerow];?></h1>
				<a href="gallery/gallerydetails.php?gallery=<?php echo $arrID[6 + $pagerow]; ?>" >
				<img class="g_size" src="gallery/galleryimages/<?php echo $arrgallery[6 + $pagerow]; ?>"/></a>
			</div>
			<?php
			}
			?>
            <div class="box_razd"></div>
			<?php 
			if((7 + $pagerow)<count($arrTitle) )
			{
			?>
			<div class="box_img2">
				<h1>&nbsp;&nbsp;<?php echo $arrTitle[7 + $pagerow]; ?></h1>
				<h1>&nbsp;&nbsp;Date : <?php echo $arrDate[7+$pagerow];?></h1>
				<a href="gallery/gallerydetails.php?gallery=<?php echo $arrID[7 + $pagerow]; ?>" >
				<img class="g_size" src="gallery/galleryimages/<?php echo $arrgallery[7 + $pagerow]; ?>"/></a>
			</div>
			<?php
			}
			?>
			<div class="box_razd"></div>
            <?php 
			if((8 + $pagerow)<count($arrTitle) )
			{
			?>
			<div class="box_img2">
				<h1>&nbsp;&nbsp;<?php echo $arrTitle[8 + $pagerow]; ?></h1>
				<h1>&nbsp;&nbsp;Date : <?php echo $arrDate[8+$pagerow];?></h1>
				<a href="gallery/gallerydetails.php?gallery=<?php echo $arrID[8 + $pagerow]; ?>" >
				<img class="g_size" src="gallery/galleryimages/<?php echo $arrgallery[8 + $pagerow]; ?>"/></a>
			</div>
			<?php
			}
			?>
		</div>
		
<?php
	$temp=mysql_query("select * from gallery",$ln);	
	if(isset($_GET['search']))
	{ 
		$ch1=$_GET['search'];
		if($ch1=="All")
		{
			$temp=mysql_query("select * from gallery",$ln);	
		}
		else
		{
			$temp=mysql_query("select * from gallery where name like '$ch1%'",$ln);
		}
	}
	$cnt=mysql_num_rows($temp);
	echo "<center>";
	
	if($cnt==0)
	{
		?>
		<br /><div style="color:#FF0000; font-size:36px;text-decoration:blink">Ooops no record found...</div><br />
		<?php
	}
	else
	{
		for($i=1;$i<=ceil($cnt/$pgsize);$i++)
		{
			if(isset($_GET['search']))
			{
			?>
	  			<a class="gal_num" "href="gallery.php?search=<?php echo $_GET['search'];?>&pgno=<?php echo $i;?>"><?php echo $i;?></a>
			<?php
			}
			else
			{
			?>
				<a class="gal_num" href="gallery.php?pgno=<?php echo $i;?>"><?php echo $i;?></a>
			<?php
			}
		}
	}
?>

<!-- ####################################################################################################### -->
</div>
<div></div></div>

</body>
</html>