<?php include('up_index.php');?>
<?php include('admin.php');?>
<center>
    <br/>
	<script src="show.js"></script>
	 <div class="table_product_show">
	 <br/>
    <table width="200" border="0">
  <tr>
	<td><a href="menu_admin.php"><div class="link3">จัดการระบบ</div></a></td>
  </tr>
</table>
    <br/>
	<table width="800" border="1" cellpadding="0" cellspacing="0">
  <tr>
    <td width="140" align="center">Username</td>
    <td width="193" align="center">ชื่อ - นามสกุล</td>
    <td width="163" align="center">เบอร์โทรศัพท์</td>
    <td width="165" align="center">E-mail</td>
    <td width="105" align="center">จัดการ</td>
  </tr>
<?php

	$strSQL = "SELECT * FROM members ";
	$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
	$Num_Rows = mysql_num_rows($objQuery);
	
	$Per_Page = 20;   // Per Page
	
	$Page = $_GET["Page"];
	if(!$_GET["Page"])
	{
		$Page=1;
	}
	
	$Prev_Page = $Page-1;
	$Next_Page = $Page+1;
	
	$Page_Start = (($Per_Page*$Page)-$Per_Page);
	if($Num_Rows<=$Per_Page)
	{
		$Num_Pages =1;
	}
	else if(($Num_Rows % $Per_Page)==0)
	{
		$Num_Pages =($Num_Rows/$Per_Page) ;
	}
	else
	{
		$Num_Pages =($Num_Rows/$Per_Page)+1;
		$Num_Pages = (int)$Num_Pages;
	}
	
	$strSQL .="  LIMIT $Page_Start , $Per_Page";
	$objQuery  = mysql_query($strSQL);

	while ($objResult  = mysql_fetch_array($objQuery))
	{
		echo "<tr>
			<td>".$objResult ['user']."</td>
			<td>".$objResult ['fname']." ".$objResult['lname']."</td>
			<td>".$objResult ['tel']."</td>
			<td>".$objResult ['email']."</td>
			<td align=\"center\"><a href=\"update_user.php?user=".$objResult ['user']."\"><img src=\"images/refresh.png\" width=\"30\"  /> </a><a href=\"save_delete_user.php?user=".$objResult ['user']."\"onclick=\"return confirm('ยืนยันการลบข้อมูล?')\"><img src=\"images/delete.png\" width=\"30\"  /></a></td>
		</tr>";
		
	}	
	?>
  </table>
	<br/>
	<?php
	if($Prev_Page)
{
	echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> ";
}

for($i=1; $i<=$Num_Pages; $i++){
	if($i != $Page)
	{
		echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
	}
	else
	{
		echo "<b> $i </b>";
	}
}
if($Page!=$Num_Pages)
{
	echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> ";
}

?>
</div>
</center>

<?php include('down_index.php'); ?>