<?php include('up_index.php');?>
<script language="javascript">
$(document).ready(function(e) {
	$("#formcategory,#form_category2").hide();
	$("#form_category").click(function(){
		$("#formcategory,#form_category2").fadeIn(0);
		$("#form_category").fadeOut(0);
	});
	$("#form_category2").click(function(){
		$("#form_category").fadeIn(0);
		$("#formcategory,#form_category2").fadeOut(0);
	});
	
	$("#id_category").keyup(function(){
		var elem = document.getElementById('id_category').value;
		if(!elem.match(/^([a-z0-9\_])+$/i))
		{
			$("#id_categoryok").html("<font color=\"#FF0000\">อักษรภาษาอังกฤษเท่านั้น</form>");
		}else{
			$("#id_categoryok").html("");
		}
	});
	
	$("#category").submit(function(){
		var elem = document.getElementById('id_category').value;
		if(!elem.match(/^([a-z0-9\_])+$/i))
		{
			return false;
		}else{
			return true;
		}
	});
	
});
</script>
<center>
    <br/>
		 <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>
    <td><a class="alink" href="add_product.php"><div class="link3">เพิ่มสินค้า</div></a></td>
	<td><div class="link3" id="form_category"><font color="#FFFFFF">เพิ่ม</font></div><div class="link3" id="form_category2">ปิด</div></td>
  </tr>
</table>
    <br/>

 
<form id="category" name="category" method="post" action="save_add_category.php">
  <table id="formcategory" width="446" border="0" cellpadding="1" cellspacing="1">
  <tr>
    <td width="161">รหัสประเภทสินค้า :</td>
    <td width="269"><input name="id_category" type="text" id="id_category" size="5" maxlength="10" /><span id="id_categoryok"  style="color: red"></span></td>
    </tr>
  <tr>
    <td>ประเภทสินค้า :</td>
    <td><input name="name_category" type="text" id="name_category" maxlength="100" /></td>
    </tr>
  <tr>
    <td>รายละเอียด :</td>
    <td><textarea name="detail" cols="30" rows="7" id="detail"></textarea></td>
    </tr>
  <tr>
    <td colspan="2" align="center"><input type="submit" name="button" id="button" value="บันทึก" />
      <input type="reset" name="button2" id="button2" value="Reset" /></td>
    </tr>
</table>
</form>




<p>&nbsp;</p>
<table width="700" border="1" cellpadding="0" cellspacing="0">
  <tr>
    <td width="200" align="center">ประเภทสินค้า</td>
    <td width="400" align="center">รายละเอียด</td>
    <td width="100" align="center">จัดการ</td>
  </tr>
  

<?php
$sql2 = "select * from category";
			$result2 = mysql_query($sql2);
			while ($category = mysql_fetch_array($result2))
			{	?>
  <tr>
    <td align="left" valign="top"><?=$category['name_category'];?></td>
    <td align="left" valign="top"><?=$category['detail'];?></td>
    <td align="center" valign="top">
    	<a href="update_category.php?id_category=<?=$category['id_category'];?>"><img src="images/refresh.png" width="30"  /> </a>
        <a href="save_delete_category.php?id_category=<?=$category['id_category'];?>" onclick="return confirm('ยืนยันการลบข้อมูล?')"><img src="images/delete.png" width="30"  /></a>
    </td>
  </tr>

            	
		<?php	}	?>
</table>
<br/>
</center>
</div>
<?php include('down_index.php'); ?>