<?php
session_start();
include '../../Connections/connect_mysql.php';
?>

<table id="tabledepart" class="table table-striped table-bordered">
	<thead>
		<tr>
			<th>รหัสแผนก</th>
			<th>ชื่อแผนก</th>
			<th>แก้ไข/ลบ</th>
		</tr>
	</thead>
	<?php $sql_dep = 'SELECT * FROM department_tb'; 
          $objdep = mysql_query($sql_dep)?>
	<tbody>
	<?php while ($rowdep = mysql_fetch_array($objdep)) { 
		$depid = $rowdep['dpmid'];
		$depcode = $rowdep['dpmcode'];
		$depname = $rowdep['dpmname'];
		?>

		<tr>
			<td><?php echo $depcode;?></td>
			<td><?php echo $depname;?></td>
			<td><button type="button" class="btn btn-warning btn-xs" onclick="javascript:btn_edit_depart(<?=$depid ?>);"><i class="fa fa-pencil"></i> แก้ไข</button>
				<button type="button" class="btn btn-danger btn-xs" onclick="javascript:btn_delete_depart(<?=$depid ?>,'<?=$depname ?>');"><i class="fa fa-trash-o"></i> ลบ</button>
			</td>
		</tr>
	<?php }mysql_close($c); ?>
	</tbody>
</table>
<script>
    $(function() {
       $("#tabledepart").DataTable();
    });
</script>