|
|
|
รบกวนอย่างแรงครับผม ช่วยในเรื่องการ query ข้อมูลแสดงออกหน้าโปรแกรมด้วยครับ |
|
|
|
|
|
|
|
code ครับ showdata.php
Code (PHP)
<?
include("connect.php");
$strSQL = "SELECT tb_name.*,tb_work.* FROM tb_name,tb_work WHERE tb_name.name_id=tb_work.work_id";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
mysql_query("SET NAMES TIS620");
$Per_Page = 10; // 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 name_id,work_id ASC LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620">
<title>:: Ãкº¢éÍÁÙźؤÅÒ¡ÃÍ͹äÅ·ì ::</title>
<style>
BODY {
FONT-FAMILY: Arial, Helvetica, sans-serif
}
</style>
</head>
<body background="images/bg4.jpg">
<div align="center"><img src="images/nfe.png" width=100 height=100></div>
<center>
<font color="#3300CC" size="4" ><h>Ãкº¢éÍÁÙźؤÅÒ¡ÃÍ͹äÅ·ì</h1></font></center>
<p align="center">
<font size="2">
<a href="search.php">| ¤é¹ËҺؤÅÒ¡Ã |</a>
<a href="index.php">| ÍÍ¡¨Ò¡Ãкº |</a> </font></p>
<p align="center"><u><b><font size="3" color="#FF0066">
| ÃÒ¢éÍÁÙźؤÅÒ¡Ã |</font></b></u></p>
<center>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#FFFFFF" width="900"
id="AutoNumber1">
<tr>
<td width="5" bgcolor="#00FFFF"> <p align="center"><font color="#000000" size="2">ÅӴѺ</font></p></td>
<!--<td width="150" bgcolor="#00FFFF"> <p align="center"><font color="#000000" size="2">ËÁÒÂàÅ¢ºÑµÃ»ÃЪҪ¹</font></p></td>-->
<td width="40"bgcolor="#00FFFF"><p align="center"><font color="#000000" size="2">¤Ó¹Ó˹éÒ</font></p></td>
<td width="60"bgcolor="#00FFFF"><p align="center"><font color="#000000" size="2">ª×èÍ</font></p></td>
<td width="60"bgcolor="#00FFFF"><p align="center"><font color="#000000" size="2">¹ÒÁÊ¡ØÅ</font></p></td>
<td width="100"bgcolor="#00FFFF"><p align="center"><font color="#000000" size="2">µÓá˹è§</font></p></td>
<td width="100"bgcolor="#00FFFF"><p align="center"><font color="#000000" size="2">˹èǧҹ</font></p></td>
<td width="50"bgcolor="#00FFFF"><p align="center"><font color="#000000" size="2">àÅ¢·Õèà§Ô¹à´×͹ </font></p></td>
<td width="20"bgcolor="#00FFFF"><p align="center"><font color="#000000" size="2">ÃÒ¡ÒûÃÐÇѵÔ</font></p></td>
</tr>
<?
$i=1;
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td width="5" height="30 "bgcolor="#CCCCFF" ><p align="center"><?=$i ; ?></td>
<!--<td width="30" bgcolor="#CCCCFF" ><div align="center"><?php echo$objResult['cid'] ; ?></div></td>-->
<td width="50" bgcolor="#CCCCFF" ><div align="center"><?php echo$objResult['fn'] ; ?></div></td>
<td width="50" bgcolor="#CCCCFF" ><div align="center"><?php echo$objResult['name'] ; ?></div></td>
<td width="50" bgcolor="#CCCCFF" ><div align="center"><?php echo$objResult['fname'] ; ?></div></td>
<td width="150" bgcolor="#CCCCFF" ><div align="center"><?php echo $objResult['position'] ; ?></div></td>
<td width="250" bgcolor="#CCCCFF" ><div align="center"><?php echo $objResult['dept'] ; ?></div></td>
<td width="20" bgcolor="#CCCCFF" ><div align="center"><?php echo $objResult['num_salary'] ; ?></div></td>
<td width="50" bgcolor="#CCCCFF" align="center"><center><a href="detail.php?id=<?=$objResult['name_id'];?>" OnClick="return Conf(this)"><img src="edit.png" width="15" height="15" border="0"></a></center></td>
</tr>
<?php
$i++;
}
?>
</table>
</center>
<div align="center">
<font color="#0033CC" size="2">¨Ó¹Ç¹ÃÒ¡Ò÷Ñé§ËÁ´ <?= $Num_Rows;?> ÅӴѺ : <?=$Num_Pages;?> ˹éÒ : </font>
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'>¶Í¡ÅѺ</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'>˹éҶѴä»</a> ";
}
?>
</body>
</html>
<br>
<br>
<br>
<br>
<?php include("footer.php")?>
</body>
</html>
|
|
|
|
|
Date :
2011-08-15 17:00:17 |
By :
tossa |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
detail.php ครับ ที่จะโชว์รายละเอียดของแต่ละคนที่คลิก
Code (PHP)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> ¢éÍÁÙźؤÅÒ¡Ã</TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<style type="text/css">
<!--
.style2 {font-size: small}
-->
</style></head>
<body>
<?include("connect.php");
$strSQL = "SELECT tb_name.*,tb_person.*,tb_education.*,tb_work.* FROM tb_name,tb_person,tb_education,tb_work ";
//$strSQL = "SELECT * FROM tb_name,tb_person,tb_education,tb_work order by name_id,person_id,edu_id,work_id asc";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
mysql_query("SET NAMES TIS620");
if($Num_Rows==0){
echo "<font size=-1 face='Tahoma'>äÁèÊÒÁÒöáÊ´§¢éÍÁÙÅä´é</font><br><br>\n";
}
?>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<table width="409" border="0" align="center" >
<tr>
<td colspan="2">¢éÍÁÙÅÊèǹµÑÇ</td>
</tr>
<tr>
<td width="145">ª×èÍ-¹ÒÁÊ¡ØÅ</td>
<td width="250"><?=$objResult["name"];?> <?=$objResult["fname"];?></td>
</tr>
<tr>
<td>ËÁÒÂàÅ¢»ÃШӵÑÇ</td>
<td><?=$objResult["cid"];?></td>
</tr>
<tr>
<td>Çѹà´×͹»Õà¡Ô´</td>
<td><?=$objResult["date"];?>/<?=$objResult["month"];?>/<?=$objResult["year"];?></td>
</tr>
<tr>
<td>ʶҹÐÀÒ¾</td>
<td><?=$objResult["s_marry"];?></td>
</tr>
<tr>
<td>¤ÙèÊÁÃÊ</td>
<td><?=$objResult["marryname"];?></td>
</tr>
<tr>
<td>¨Ó¹Ç¹ºØµÃ</td>
<td><?=$objResult["child"];?></td>
</tr>
<tr>
<td>·ÕèÍÂÙè»Ñ¨¨ØºÑ¹</td>
<td><?=$objResult["address"];?></td>
</tr>
<tr>
<td>ËÁÒÂàÅ¢â·ÃÈѾ·ì</td>
<td><?=$objResult["phone"];?></td>
</tr>
<tr>
<td>ÍÕàÁÅì</td>
<td><?=$objResult["mail"];?></td>
</tr>
<tr>
<td colspan="2">»ÃÐÇѵԡÒÃÈÖ¡ÉÒ</td>
</tr>
<tr>
<td>ÇزԡÒÃÈÖ¡ÉÒ</td>
<td><?=$objResult["degree"];?></td>
</tr>
<tr>
<td>ÇÔªÒàÍ¡</td>
<td><?=$objResult["major"];?></td>
</tr>
<tr>
<td>ʶҺѹ¡ÒÃÈÖ¡ÉÒ</td>
<td><?=$objResult["institute"];?></td>
</tr>
<tr>
<td>Çѹ·Õ診¡ÒÃÈÖ¡ÉÒ</td>
<td><?=$objResult["date2"];?>/<?=$objResult["month2"];?>/<?=$objResult["year2"];?></td>
</tr>
<tr>
<td colspan="2">ʶҹ·Õè·Ó§Ò¹</td>
</tr>
<tr>
<td>µÓá˹è§</td>
<td><?=$objResult["position"];?></td>
</tr>
<tr>
<td>Êѧ¡Ñ´Ë¹èǧҹ</td>
<td><?=$objResult["dept"];?></td>
</tr>
<tr>
<td>Çѹ·ÕèºÃèØ</td>
<td><?=$objResult["date3"];?>/<?=$objResult["month3"];?>/<?=$objResult["year3"];?></td>
</tr>
<tr>
<td>àÅ¢·Õèà§Ô¹à´×͹</td>
<td><?=$objResult["num_salary"];?></td>
</tr>
</table>
<br / >
<?
}
?>
<center><img src="images/printer.png" onClick="window.print()"></center>
</body>
|
|
|
|
|
Date :
2011-08-15 17:02:54 |
By :
tossa |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แก้ที่ไฟล์ Detail.php เป็นแบบนี้ครับ
Code (PHP)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Untitled Document</TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<meta http-equiv="Content-Type" content="text/html; charset=TIS-620">
</HEAD>
<style type="text/css">
<!--
.style2 {font-size: small}
-->
</style></head>
<body>
<?php
include("connect.php");
$detail_id = $_GET['id'];
$strSQL = "SELECT tb_name.*,tb_person.*,tb_education.*,tb_work.* FROM tb_name,tb_person,tb_education,tb_work WHERE name_id='$detail_id' LIMIT 1";
//$strSQL = "SELECT * FROM tb_name,tb_person,tb_education,tb_work order by name_id,person_id,edu_id,work_id asc";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
mysql_query("SET NAMES TIS620");
if($Num_Rows==0){
echo "<font size=-1 face='Tahoma'>äÁèÊÒÁÒöáÊ´§¢éÍÁÙÅä´é</font><br><br>\n";
}
?>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<table width="409" border="0" align="center" >
<tr>
<td colspan="2">¢éÍÁÙÅÊèǹµÑÇ</td>
</tr>
<tr>
<td width="145">ª×èÍ-¹ÒÁÊ¡ØÅ</td>
<td width="250"><?=$objResult["name"];?> <?=$objResult["fname"];?></td>
</tr>
<tr>
<td>ËÁÒÂàÅ¢»ÃШӵÑÇ</td>
<td><?=$objResult["cid"];?></td>
</tr>
<tr>
<td>Çѹà´×͹»Õà¡Ô´</td>
<td><?=$objResult["date"];?>/<?=$objResult["month"];?>/<?=$objResult["year"];?></td>
</tr>
<tr>
<td>ʶҹÐÀÒ¾</td>
<td><?=$objResult["s_marry"];?></td>
</tr>
<tr>
<td>¤ÙèÊÁÃÊ</td>
<td><?=$objResult["marryname"];?></td>
</tr>
<tr>
<td>¨Ó¹Ç¹ºØµÃ</td>
<td><?=$objResult["child"];?></td>
</tr>
<tr>
<td>·ÕèÍÂÙè»Ñ¨¨ØºÑ¹</td>
<td><?=$objResult["address"];?></td>
</tr>
<tr>
<td>ËÁÒÂàÅ¢â·ÃÈѾ·ì</td>
<td><?=$objResult["phone"];?></td>
</tr>
<tr>
<td>ÍÕàÁÅì</td>
<td><?=$objResult["mail"];?></td>
</tr>
<tr>
<td colspan="2">»ÃÐÇѵԡÒÃÈÖ¡ÉÒ</td>
</tr>
<tr>
<td>ÇزԡÒÃÈÖ¡ÉÒ</td>
<td><?=$objResult["degree"];?></td>
</tr>
<tr>
<td>ÇÔªÒàÍ¡</td>
<td><?=$objResult["major"];?></td>
</tr>
<tr>
<td>ʶҺѹ¡ÒÃÈÖ¡ÉÒ</td>
<td><?=$objResult["institute"];?></td>
</tr>
<tr>
<td>Çѹ·Õ診¡ÒÃÈÖ¡ÉÒ</td>
<td><?=$objResult["date2"];?>/<?=$objResult["month2"];?>/<?=$objResult["year2"];?></td>
</tr>
<tr>
<td colspan="2">ʶҹ·Õè·Ó§Ò¹</td>
</tr>
<tr>
<td>µÓá˹è§</td>
<td><?=$objResult["position"];?></td>
</tr>
<tr>
<td>Êѧ¡Ñ´Ë¹èǧҹ</td>
<td><?=$objResult["dept"];?></td>
</tr>
<tr>
<td>Çѹ·ÕèºÃèØ</td>
<td><?=$objResult["date3"];?>/<?=$objResult["month3"];?>/<?=$objResult["year3"];?></td>
</tr>
<tr>
<td>àÅ¢·Õèà§Ô¹à´×͹</td>
<td><?=$objResult["num_salary"];?></td>
</tr>
</table>
<br / >
<?
}
?>
<center><img src="images/printer.png" onClick="window.print()"></center>
</body>
ปล. คำว่า Online ต้องเป็น ออนไลน์ ครับ ถ้าออนไลท์ = onlite
|
|
|
|
|
Date :
2011-08-15 18:16:51 |
By :
adaaugusta |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณครับ แต่ยังติดปัญหาอีกครับ
คือมันแสดงได้แค่ ชื่อและหมายเลขบัตร แต่ข้อมูลตัวอื่น
ออกมาซ้ำกันหมดเลย
|
|
|
|
|
Date :
2011-08-15 21:35:13 |
By :
tossa |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คุณลองตรวจสอบ Data ใน phpMyAdmin ครับ ว่ามันถูกต้องซ้ำกันหรือไม่
|
|
|
|
|
Date :
2011-08-16 06:43:07 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|