<?php include('open_connection.php');
      include('header.php'); ?>

<html>
<!--link href='blue/style.css' rel='stylesheet' type='text/css' /-->
<link href='css/imagetable.css' rel='stylesheet' type='text/css' />

<body>

<h2 align="center">VENDOR DIRECTORY LIST</h2>

<form action="vendor_search.php" method="post">
<table border=0 align=center  class="imagetable" >
<tr><td>INFO SEARCH</td><td><input type="text" name="directory" /><input type="submit" class="myButton"  value="SEARCH"/> &nbsp;<input type="button" value="HOME" class="myButton" onClick="window.location.href='index.php'">
 </td>
</tr>
</table>
</form>
<br>

<!--hr /-->
<div align="right">

  <?php
$rowsPerPage =20; 
				$pageNum = $_REQUEST['page']; 
				if(empty($pageNum))
						{
					$offset =0;
					$pageNum=1;
						}
				else
						{
					$offset = ($pageNum - 1) * $rowsPerPage;
						}	
					$result=mysql_query("SELECT * from tbl_dir_vendor WHERE vendor_name LIKE '%".$_POST[directory]."%' OR vendor_address1 LIKE '%".$_POST[directory]."%' OR vendor_address2 LIKE '%".$_POST[directory].		
						"%' OR vendor_address3 LIKE '%".$_POST[directory]."%' OR vendor_address4 LIKE '%".$_POST[directory]."%' OR vendor_city LIKE '%".$_POST[directory]."%' OR vendor_state LIKE '%".$_POST[directory].
						"%' OR vendor_postcode LIKE '%".$_POST[directory]."%' OR vendor_country LIKE '%".$_POST[directory]."%' OR vendor_hp1 LIKE '%".$_POST[directory]."%' OR vendor_hp2 LIKE '%".$_POST[directory].
						"%' OR vendor_hp3 LIKE '%".$_POST[directory]."%' OR vendor_fax LIKE '%".$_POST[directory]."%' OR vendor_email LIKE '%".$_POST[directory]."%' OR vendor_www LIKE '%".$_POST[directory].
						"%' OR vendor_contact LIKE '%".$_POST[directory]."%' OR vendor_salutation LIKE '%".$_POST[directory]."%' OR vendor_section LIKE '%".$_POST[directory].
						"%' ORDER BY vendor_section ASC LIMIT $offset, $rowsPerPage");
		
		  			$i=$offset;
		  
echo "<center><span class=style16><table class=tablesorter id=user>";
echo "<thead>";
echo"<tr align='center'><th>NO</th><th>NAME</th><th>ADDRESS</th><th>CONTACT</th><th>EMAIL</th><th>WEBSITE</th><th>EMAIL</th><th>SECTION</th></tr>";
echo "</thead>";
echo "<tbody>";	 
while($row=mysql_fetch_array($result))
{
					 $vendor_id = $row['vendor_id']; 
		 		   $vendor_name = $row['vendor_name'];
		     	$vendor_section = $row['vendor_section'];
			$vendor_designation = $row['vendor_designation'];
			        $vendor_ext = $row['vendor_ext'];
			         $vendor_hp = $row['vendor_hp'];
			 	   $vendor_emel = $row['vendor_emel'];
				 $vendor_assign = $row['vendor_assign'];
			$i++;
					echo"<tr>";
						echo "<td align=center>".$i."</td>";
						echo "<td align=left >".$row['vendor_name']."</td>";
						echo "<td align=center >".$row['vendor_section']."</td>";
						echo "<td align=center >".$row['vendor_designation']."</td>";
						echo "<td align=center >".$row['vendor_ext']."</td>";
						echo "<td align=center >".$row['vendor_hp']."</td>";
						echo "<td align=center >".$row['vendor_emel']."</td>";
						echo "<td align=center >".$row['vendor_assign']."</td>";
					echo"</tr>";
					}
					
					echo "</span></table>";
echo "</tbody>";
//mysql_close($con);

?>
  <div align="right"> <span class="style16"  >
    <?php
				$query1 = "SELECT COUNT(vendor_id) AS numrows FROM tbl_dir_vendor";
				$result1 = mysql_query($query1) or die('Error, query failed');
				$row1 = mysql_fetch_array($result1, MYSQL_ASSOC);
				$numrows = $row1['numrows'];
				$maxPage = ceil($numrows/$rowsPerPage);
				// print the link to access each page
				$self = $_SERVER['PHP_SELF'];
				$nav = '';
				for($page = 1; $page <= $maxPage; $page++){
				if ($page == $pageNum){
				$nav .= " $page ";}
				else{
				$nav .= " <a href=\"$self?page=$page\">$page</a> ";
					}
				}
				if ($pageNum > 1)
				{
					$page = $pageNum - 1;
					$color="#FFFFFF";
					$prev = " <a href=\"$self?page=$page\">[Previous]</a> ";
					$first = " <a href=\"$self?page=1\">[First]</a> ";
				}
					else{
					$prev = ' ';
					$first = ' ';
				}
					if ($pageNum < $maxPage)
				{
						$page = $pageNum + 1;
						$next = " <a href=\"$self?page=$page\">[Next]</a> ";
						$last = " <a href=\"$self?page=$maxPage\">[Last]</a> ";
				}
					else{
					$next = ' ';
					$last = ' ';
				}
		echo  $first . $prev . $nav . $next . $last;?>
  </span></div>
  </td>
  </tr>
      </table>
</div>
</body>
<script type='text/javascript' src='tablesorter/jquery-latest.js'>
</script>
<script type='text/javascript' src='tablesorter/jquery.tablesorter.min.js'>
</script>


<script type='text/javascript'>
	$(document).ready(function() { 
		$("#user").tablesorter({ 
			//for example we want to disable the 
			//password column (5th column) from sorting
			//we will specify '4' since it was indexed
			//(count starts at '0')
			//and set its property to 'false'
			headers: { 
				8: {    
					sorter: false 
				}
			}
		}); 
	});
	
</script>
</html>
<?php include('footer.php'); ?>
