|
|
|
แสดงรายชื่อ โดยแบ่งตามแผนก และในแต่ละแผนกให้แสดงชื่อ |
|
|
|
|
|
|
|
สอบถามหน่อยคับ คือจะให้แสดงผลในหน้าเดียว โดยแต่ละแผนกจะมีรายชื่อคนในแผนกนั้นๆ
แต่ที่ทำออกมา รายชื่อมันรวมกันที่แผนกเดียวหมดเลยคับ ตามภาพ ขอคำชี้แนะด้วยครับ
Code (PHP)
<? session_start();if($_SESSION['user'] == ""){header("location:../index.php");exit();}?>
<?php require_once('../Connections/conn.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$colname_location = "-1";
if (isset($_GET['lo_id'])) {
$colname_location = $_GET['lo_id'];
}
mysql_select_db($database_conn, $conn);
$query_location = sprintf("SELECT * FROM location WHERE id = %s", GetSQLValueString($colname_location, "int"));
$location = mysql_query($query_location, $conn) or die(mysql_error());
$row_location = mysql_fetch_assoc($location);
$totalRows_location = mysql_num_rows($location);
$colname_dept = "-1";
if (isset($_GET['lo_id'])) {
$colname_dept = $_GET['lo_id'];
}
mysql_select_db($database_conn, $conn);
$query_dept = sprintf("SELECT * FROM dept WHERE location_id = %s", GetSQLValueString($colname_dept, "int"));
$dept = mysql_query($query_dept, $conn) or die(mysql_error());
$row_dept = mysql_fetch_assoc($dept);
$totalRows_dept = mysql_num_rows($dept);
$colname_list = "-1";
$aa =$row_list['name_th'];
if (isset($_GET['lo_id'])) {
$colname_list = $_GET['lo_id'];
}
mysql_select_db($database_conn, $conn);
$query_list = sprintf("SELECT * FROM list WHERE location =%s", GetSQLValueString($colname_list, "text"));
$list = mysql_query($query_list, $conn) or die(mysql_error());
$row_list = mysql_fetch_assoc($list);
$totalRows_list = mysql_num_rows($list);
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head><body>
<div style="height:30px;"><a href="index.php?p=home"><img src="../img/home.png" width="24" height="24" /> Home </a></div>
<div class="panel panel-default">
<!-- Default panel contents -->
<div class="panel-heading"><strong><?php echo $row_location['location']; ?><br />
</strong><?php echo $row_location['l1']; ?> <br />
<?php echo $row_location['l2']; ?> <br />
<?php echo $row_location['l3']; ?> <strong><br />
</strong></div>
<?php do { ?>
<div name="dept" >
<?php echo $row_dept['dept_name']; ?><?php echo $row_dept['location_id']; ?>
<table class="table table-bordered">
<tr>
<td height="30"><div align="center"><strong>No.</strong></div></td>
<td><div align="center"><strong>Name </strong></div></td>
<td><div align="center"><strong>Nickname</strong></div></td>
<td><div align="center"><strong>Title</strong></div></td>
<td><div align="center"><strong>Ext</strong></div></td>
<td><div align="center"><strong>Mobile</strong></div></td>
<?php if ( $_SESSION['user'] ==anupong ){ ?>
<td><div align="center"><strong>Edit</strong></div></td>
<td><div align="center"><strong>Del</strong></div></td><?php }?>
</tr> <?php do { $i++; if($i%2==0) { $bg="";}else{$bg="#edeff0";} ?>
<tr bgcolor="<?=$bg; ?>" onmouseover="this.style.backgroundColor='#bfdbf4'" onmouseout="this.style.backgroundColor= ''">
<td><div align="center">
<?=$i;?>
</div></td>
<td><strong><?php echo $row_list['name_th']; ?><br />
</strong></td>
<td><?php echo $row_list['nickname']; ?></td>
<td> </td>
<td> </td>
<td> </td>
<?php if ( $_SESSION['user'] ==anupong){ ?>
<td><div align="center"><a href=""><img src="../img/edit.png" width="20" height="20" alt="edit" /></a></div></td>
<td><div align="center"><a href="" onclick="return confirm('คุณแน่ใจที่จะลบข้อมูลนี้ ?')"><img src="../img/delete.gif" width="16" height="16" alt="del" /></a></div></td> <?php }?>
<?php } while ($row_list = mysql_fetch_assoc($list)); ?>
</tr>
</table></div>
<?php } while ($row_dept = mysql_fetch_assoc($dept)); ?>
</div>
</body>
</html>
<?php
mysql_free_result($location);
mysql_free_result($dept);
mysql_free_result($list);
?>
Tag : PHP
|
|
|
|
|
|
Date :
2015-07-09 18:53:12 |
By :
llwnlnsu |
View :
1185 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณคับ
|
|
|
|
|
Date :
2015-07-11 10:31:53 |
By :
llwnlnsu |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|