สอบถาม คลิกที่รูปแล้วให้โชว์ข้อมูลที่เราเลือกจากdata base ครับ
อันนี้codeหน้าตารางหลัก
Code (PHP)
<?
class Paginator{
var $items_per_page;
var $items_total;
var $current_page;
var $num_pages;
var $mid_range;
var $low;
var $high;
var $limit;
var $return;
var $default_ipp;
var $querystring;
var $url_next;
function Paginator()
{
$this->current_page = 1;
$this->mid_range = 7;
$this->items_per_page = $this->default_ipp;
$this->url_next = $this->url_next;
}
function paginate()
{
if(!is_numeric($this->items_per_page) OR $this->items_per_page <= 0) $this->items_per_page = $this->default_ipp;
$this->num_pages = ceil($this->items_total/$this->items_per_page);
if($this->current_page < 1 Or !is_numeric($this->current_page)) $this->current_page = 1;
if($this->current_page > $this->num_pages) $this->current_page = $this->num_pages;
$prev_page = $this->current_page-1;
$next_page = $this->current_page+1;
if($this->num_pages > 10)
{
$this->return = ($this->current_page != 1 And $this->items_total >= 10) ? "<a class=\"paginate\" href=\"".$this->url_next.$this->$prev_page."\">« Previous</a> ":"<span class=\"inactive\" href=\"#\">« Previous</span> ";
$this->start_range = $this->current_page - floor($this->mid_range/2);
$this->end_range = $this->current_page + floor($this->mid_range/2);
if($this->start_range <= 0)
{
$this->end_range += abs($this->start_range)+1;
$this->start_range = 1;
}
if($this->end_range > $this->num_pages)
{
$this->start_range -= $this->end_range-$this->num_pages;
$this->end_range = $this->num_pages;
}
$this->range = range($this->start_range,$this->end_range);
for($i=1;$i<=$this->num_pages;$i++)
{
if($this->range[0] > 2 And $i == $this->range[0]) $this->return .= " ... ";
if($i==1 Or $i==$this->num_pages Or in_array($i,$this->range))
{
$this->return .= ($i == $this->current_page And $_GET['Page'] != 'All') ? "<a title=\"Go to page $i of $this->num_pages\" class=\"current\" href=\"#\">$i</a> ":"<a class=\"paginate\" title=\"Go to page $i of $this->num_pages\" href=\"".$this->url_next.$i."\">$i</a> ";
}
if($this->range[$this->mid_range-1] < $this->num_pages-1 And $i == $this->range[$this->mid_range-1]) $this->return .= " ... ";
}
$this->return .= (($this->current_page != $this->num_pages And $this->items_total >= 10) And ($_GET['Page'] != 'All')) ? "<a class=\"paginate\" href=\"".$this->url_next.$next_page."\">Next »</a>\n":"<span class=\"inactive\" href=\"#\">» Next</span>\n";
}
else
{
for($i=1;$i<=$this->num_pages;$i++)
{
$this->return .= ($i == $this->current_page) ? "<a class=\"current\" href=\"#\">$i</a> ":"<a class=\"paginate\" href=\"".$this->url_next.$i."\">$i</a> ";
}
}
$this->low = ($this->current_page-1) * $this->items_per_page;
$this->high = ($_GET['ipp'] == 'All') ? $this->items_total:($this->current_page * $this->items_per_page)-1;
$this->limit = ($_GET['ipp'] == 'All') ? "":" LIMIT $this->low,$this->items_per_page";
}
function display_pages()
{
return $this->return;
}
}
?>
<!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" />
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<link rel="icon" href="images/etc/favicon.ico" type=”image/x-icon” />
<link href="css/screen.css" rel="stylesheet" type="text/css" media="screen" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link href="css/front.css" media="screen, projection" rel="stylesheet" type="text/css">
<script src="js/jquery1.7.1.js" type="text/javascript"></script>
<script src="js/main6.js" type="text/javascript"></script>
<script src="js/ga_social_tracking.js" type="text/javascript"></script>
<title>test</title>
</head>
<style type="text/css">
<!--
.paginate {
font-family: Arial, Helvetica, sans-serif;
font-size: .7em;
}
a.paginate {
border: 1px solid #000080;
padding: 2px 6px 2px 6px;
text-decoration: none;
color: #000080;
}
h2 {
font-size: 12pt;
color: #003366;
}
h2 {
line-height: 1.2em;
letter-spacing:-1px;
margin: 0;
padding: 0;
text-align: left;
}
a.paginate:hover {
background-color: #000080;
color: #FFF;
text-decoration: underline;
}
a.current {
border: 1px solid #000080;
font: bold .7em Arial,Helvetica,sans-serif;
padding: 2px 6px 2px 6px;
cursor: default;
background:#000080;
color: #FFF;
text-decoration: none;
}
span.inactive {
border: 1px solid #999;
font-family: Arial, Helvetica, sans-serif;
font-size: .7em;
padding: 2px 6px 2px 6px;
color: #999;
cursor: default;
}
div#login_div{
position:relative;
margin:auto;
display:none;
width:100%;
height:150px;
background-color:#FFFFCC; }
-->
</style>
<script language="javascript">
function js_popup(theURL,width,height) { //v2.0
leftpos = (screen.availWidth - width) / 2;
toppos = (screen.availHeight - height) / 2;
window.open(theURL, "viewdetails","width=" + width + ",height=" + height + ",left=" + leftpos + ",top=" + toppos);
}
</script>
<div class=" shadow">
<div id="mainmenu">
<? include "menu.php"; ?>
</div>
<div id="header"><? include "head.php"; ?>
</div>
<div id="con"></div>
<?
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("request");
mysql_query("SET NAMES 'tis620'");
mysql_query("SET NAMES UTF8");
$strSQL = "SELECT * FROM job";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 30; // 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 .=" order by job_id ASC LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="center"><font size="3"><span class="style11">แสดงข้อมูลการขอใช้บริการ IT Support Online </span></font></div>
</td>
</tr>
</table>
<br>
<table width="100%" border="1" cellpadding="0">
<tr>
<th width="69"bgcolor="#88D5E7"> <div align="center">ลำดับ</div></th>
<th width="69"bgcolor="#88D5E7"> <div align="center">เลขที่</div></th>
<th width="203"bgcolor="#88D5E7"> <div align="center">ผู้แจ้ง</div></th>
<th width="74"bgcolor="#88D5E7"> <div align="center">รหัสพนักงาน</div></th>
<th width="122"bgcolor="#88D5E7"> <div align="center">แผนก</div></th>
<th width="68"bgcolor="#88D5E7"> <div align="center">เบอร์ภายใน</div></th>
<th width="108"bgcolor="#88D5E7"> <div align="center">วันที่แจ้ง</div></th>
<th width="267"bgcolor="#88D5E7"> <div align="center">ความต้องการ</div></th>
<th width="65"bgcolor="#88D5E7"> <div align="center">รายละเอียด</div></th>
<th width="65"bgcolor="#88D5E7"> <div align="center">สถานะ </div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
$job_date = $objResult["job_date"];
$d = substr($job_date,8,2); //วันที่
$m= substr($job_date,5,2); //เดือน
$y = substr($job_date,2,2); //ปี
$job_id = $objResult["job_id"];
$code = sprintf ("IT$y/$m/%03d",$job_id);
$job_detail = $objResult["job_detail"];
?>
<tr>
<td width="69"><div align="center"><?=$objResult["job_id"];?></div></td>
<td width="69"><div align="center"><?=$code;?></div></td>
<td width="203"><div align="center"><?=$objResult["job_fnameEng"];?> <?=$objResult["job_lnameEng"];?></div></td>
<td width="74"><div align="center"><?=$objResult["per_id"];?></div></td>
<td width="122">
<?
$dep_id = $objResult["job_dep_id"];
?>
<?
$strSQL3 ="SELECT*FROM dep where dep_id='$dep_id' ";
$objQuery3 = mysql_query($strSQL3);
$Num_Rows3 = mysql_num_rows($objQuery3);
while($objResult3 = mysql_fetch_array($objQuery3))
{
?>
<div align="center"><?=$objResult3["dep_name"];?></div></td>
<?
}
?>
<td width="68"><div align="center"><?=$objResult["job_tel"];?></div></td>
<td width="108"><div align="center"><?=$objResult["job_date"];?>[<?=$objResult["job_time"];?>]</div></td>
<td width="267">
<?
$type_id = $objResult["job_type_id"];
?>
<?
$strSQL3 ="SELECT*FROM type where type_id='$type_id' ";
$objQuery3 = mysql_query($strSQL3);
$Num_Rows3 = mysql_num_rows($objQuery3);
while($objResult3 = mysql_fetch_array($objQuery3))
{
?>
<div align="center"><?=$objResult3["type_name"];?></div></td>
<?
}
?>
<td width="65"><div align="center"><a href="#" onClick="js_popup('view.php?id_edit=$job_id',700,580); return false;" title="รายละเอียด"><img src="images/detail.jpg" /></a></div></td>
<td width="65">
<?
$status_id = $objResult["job_status"];
?>
<?
$strSQL3 ="SELECT*FROM status where status_id='$status_id' ";
$objQuery3 = mysql_query($strSQL3);
$Num_Rows3 = mysql_num_rows($objQuery3);
while($objResult3 = mysql_fetch_array($objQuery3))
{
?>
<div align="center"><img src="admin/myfile/<?=$objResult3["status_pic"];?>"/></div></td>
<?
}
?>
</tr>
<?
}
?>
</table>
<br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="center">
ทั้งหมด <?= $Num_Rows;?> รายการ
<?
$pages = new Paginator;
$pages->items_total = $Num_Rows;
$pages->mid_range = 10;
$pages->current_page = $Page;
$pages->default_ipp = $Per_Page;
$pages->url_next = $_SERVER["PHP_SELF"]."?QueryString=value&Page=";
$pages->paginate();
echo $pages->display_pages()
?>
<?
mysql_close($objConnect);
?>
</div></td>
</tr>
</table>
<p> </p>
</div>
<div class="clear"></div>
</div></div>
<div class="bottombar2">
<table width="950">
<tr>
<td width="299"> </td>
<td width="336"> </td>
<td width="299"> </td>
</tr>
</table>
<p> </p>
</div>
</body></html>
ส่วนอันนี้codeหน้าที่โชว์ข้อมูลทั้งหมด(พอกดที่รูปจากหน้าหลักจะเด้งหน้านี้ขึ้นมา)
Code (PHP)
<?
$id_edit=$_GET[id_edit];
include"connect.php";
//$sql="select * from job where job_id='$id_edit'";
$sql="select job.job_id,job.per_id,job.job_fnameth,job.job_lnameth,job.job_fnameEng,job.job_lnameEng,job.job_tel,job.job_status,job.job_date ,job.job_time,job.job_result,job.job_ansname,dep.dep_name,type.type_name
from job,dep,type
where job.job_dep_id=dep.dep_id and job.job_type_id=type.type_id and job.job_id='$id_edit'";
$result=mysql_db_query($dbname,$sql);
$rs=mysql_fetch_array($result);
$job_date=$rs[job_date];
$job_time=$rs[job_time];
$job_fnameth=$rs[job_fnameth];
$job_lnameth=$rs[job_lnameth];
$job_fnameEng=$rs[job_fnameEng];
$job_lnameEng=$rs[job_lnameEng];
$per_id=$rs[per_id];
$dep_name=$rs[dep_name];
$job_tel=$rs[job_tel];
$type_name=$rs[type_name];
$job_detail=$rs[job_detail];
$job_status=$rs[job_status];
$job_ansname=$rs[job_ansname];
$job_result=$rs[job_result];
?>
<!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" />
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<title>test</title>
</head>
<body>
<div align="center"><br>
<form name="form1" method="post" action="view1.php">
<table width="500" border="0" cellspacing="5" cellpadding="0">
<tr bgcolor="#FFFFFF">
<td height="30" colspan="2"> </td>
</tr>
<tr bgcolor="#88D5E7">
<td height="30" colspan="2"><div align="center" class="unnamed1">
test</div></td>
</tr>
<tr class="unnamed1">
<td width="34%"><div align="right"><strong>วันที่ เวลา : </strong></div></td>
<td width="60%"><?=$job_date?> <?=$job_time?> </td>
</tr>
<tr class="unnamed1">
<td colspan="2"><hr></td>
</tr>
<tr class="unnamed1">
<td><div align="right"><strong>ผู้แจ้ง(ภาษาไทย) : </strong></div></td>
<td>
<?=$job_fnameth?> <?=$job_lnameth?>
</td>
</tr>
<tr class="unnamed1">
<td><div align="right"><strong>ผู้แจ้ง(ภาษาอังกฤษ) : </strong></div></td>
<td>
<input name="job_Engname" type="text" value="<?=$objResult["job_fnameEng"];?> <?=$objResult["job_lnameEng"];?>"disabled>
</td>
</tr>
<tr class="unnamed1">
<td><div align="right"><strong>รหัสพนักงาน : </strong></div></td>
<td>
<input name="job_per" type="text" value="<?=$objResult["per_id"];?>"disabled>
</td>
</tr>
<tr class="unnamed1">
<td><div align="right"><strong>แผนก : </strong></div></td>
<td><input name="job_dep" type="text" value="
<?
$dep_id = $objResult["job_dep_id"];
?>
<?
$strSQL3 ="SELECT*FROM dep where dep_id='$dep_id' ";
$objQuery3 = mysql_query($strSQL3);
$Num_Rows3 = mysql_num_rows($objQuery3);
while($objResult3 = mysql_fetch_array($objQuery3))
{
?>
<div align="center"><?=$objResult3["dep_name"];?> </div> </td>
<?
}
?>
"disabled>
</td>
</tr>
<tr class="unnamed1">
<td><div align="right"><strong>เบอร์ติดต่อภายใน : </strong></div></td>
<td><input name="job_tel" type="text" value="
<?=$objResult["job_tel"];?>"disabled>
</td>
</tr>
<tr class="unnamed1">
<td colspan="2"><hr></td>
</tr>
<tr class="unnamed1">
<td><div align="right"><strong>ความต้องการ : </strong></div></td>
<td><input name="job_type" type="text" value="
<?
$type_id = $objResult["job_type_id"];
?>
<?
$strSQL3 ="SELECT*FROM type where type_id='$type_id' ";
$objQuery3 = mysql_query($strSQL3);
$Num_Rows3 = mysql_num_rows($objQuery3);
while($objResult3 = mysql_fetch_array($objQuery3))
{
?>
<div align="center"><?=$objResult3["type_name"];?></div></td>
<?
}
?> "disabled>
<td width="6%"></td>
</tr>
<tr class="unnamed1">
<td valign="top"><div align="right"><strong>รายละเอียด : </strong></div></td>
<td><input name="job_detail" type="text" value="<?=$objResult["job_detail"];?>"disabled>
</td>
</tr>
<tr class="unnamed1">
<td><div align="right"><strong>สถานะงาน : </strong></div></td>
<td><input name="job_status" type="text" value="
<?
$status_id = $objResult["job_status"];
?>
<?
$strSQL3 ="SELECT*FROM status where status_id='$status_id' ";
$objQuery3 = mysql_query($strSQL3);
$Num_Rows3 = mysql_num_rows($objQuery3);
while($objResult3 = mysql_fetch_array($objQuery3))
{
?>
<div align="center"><?=$objResult3["status_name"];?></div></td>
<?
}
?>
"disabled>
</td>
</tr>
<tr class="unnamed1">
<td colspan="2"><hr></td>
</tr>
<tr class="unnamed1">
<td><div align="right"><strong>ผู้รับงาน : </strong></div></td>
<td><input name="job_ansname" type="text" value="<?=$objResult["job_ansname"];?>"disabled></td>
</tr>
<tr class="unnamed1">
<td><div align="right"><strong>ระยะเวลาซ่อม : </strong></div></td>
<td><input name="job_date" type="text" value="
<?=$objResult["job_udate"];?>"disabled></td>
</tr>
<tr class="unnamed1">
<td><div align="right"><strong>สรุปผลการซ่อม : </strong></div></td>
<td><input name="job_result" type="text" value="<?=$objResult["job_result"];?>"disabled></td>
</tr>
<tr class="unnamed1">
<td colspan="2"><div align="right"><hr></div>
</td>
</tr>
<tr class="unnamed1">
<td colspan="3" valign="top"><div align="center">
<input type="submit" name="Submit" value="Close" Onclick="JavaScript:window.opener.location.reload(); window.close();" />
</div></td></tr>
</table>
</form>
<br>
</div>
</body>
</html>
ขอบคุณครับTag : PHP, HTML/CSS, JavaScript
Date :
2013-07-08 14:06:36
By :
ruud
View :
853
Reply :
2
Code (PHP)
<a href="#" onClick="js_popup('view.php?id_edit=<?php echo $job_id;?>',700,580); return false;" title="รายละเอียด">
Code (PHP)
<?
$idedit=$_GET[id_edit];
include"connect.php";
//$sql="select * from job where job_id='$id_edit'";
$sql="select job.job_id,job.per_id,job.job_fnameth,job.job_lnameth,job.job_fnameEng,job.job_lnameEng,job.job_tel,job.job_status,job.job_date ,job.job_time,job.job_result,job.job_ansname,dep.dep_name,type.type_name
from job
inner join dep on dep.dep_id=job.job_dep_id
inner join type on job.job_type_id=type.type_id
where job.job_id='$idedit'";
?>
ประวัติการแก้ไข 2013-07-08 19:48:26
Date :
2013-07-08 19:43:31
By :
compiak
Load balance : Server 03