|
 |
|
การคัดลอกตาราง ตอนนี้ได้สร้างตารางค้นหาข้อมูลขึ้นมาและแสดงผลในหน้าเดียวกัน |
|
 |
|
|
 |
 |
|
คืออย่างนี้คะ แพรสร้างตัวค้นหาข้อมูลและแสดงข้อมุลได้แล้วคะ
แต่ว่าหน้าค้นหากับหน้าแสดงข้อมูลมันอยู่หน้าเดียวกัน แพรต้องการที่จะสร้างหน้ารายงานใหม่โดยเอาข้อมูลที่ค้นหาได้ไปแสดงนะคะไม่ทราบว่ามีวิธีการไหนบ้างคะ
|
 |
 |
 |
 |
Date :
2009-07-24 15:09:34 |
By :
preapo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ก็ทำเหมือนตอนที่แสดง ผลจากการค้นหา นั่นล่ะครับ
ตัดส่วนที่ใช้สำหรับกรอกคำค้นออกก็เรียบร้อย
|
 |
 |
 |
 |
Date :
2009-07-24 15:15:43 |
By :
lozomac |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แล้วใช้คำสั่งอะไรในการเชื่อมต่อตารางคะ
|
 |
 |
 |
 |
Date :
2009-07-24 15:24:06 |
By :
preapo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองโค้ดมาแปะให้ดูหน่อยครับ
|
 |
 |
 |
 |
Date :
2009-07-24 15:51:12 |
By :
lozomac |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
<?php require_once('conn.php');
if(!$_SESSION['admin']){
echo "<meta http-equiv='refresh' content='0;url=index.php'>";
exit();
}
if(($_SESSION['admin_array']['p_pos']!=='manager') ){
echo "<meta http-equiv='refresh' content='0;url=error.php'>";
exit();
}?>
<html>
<title>ระบบรายงานการปฎิบัติงาน</title>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<link href="calendar-mos.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {font-size: small}
-->
</style>
</head>
<body topmargin="0" rightmargin="0" leftmargin="0" bottommargin="0">
<?php include('head.php'); ?>
<div align="left">
<div align="right">
<table width="975" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td width="271"><?php echo 'ยินดีต้อนรับ',$_SESSION['admin_array']['username']; ?></td>
<td width="693"><div align="right"> <a href="index.php">ออกจากระบบ</a></div></td>
</tr>
</table>
</div>
</div>
<div align="right">
<script language="JavaScript" src="calendar.js"></script>
</div>
<form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>">
<br>
<table width="599" border="1" align="center" bgcolor="#EAFCFD">
<tr>
<th><select name="user_id">
<option value="" selected>--กรุณาเลือกรายชื่อบุคคลากร--</option>
<option value="0" >--เลือกทั้งหมด--</option>
<?php
$sql = "SELECT * FROM personal order by user_id ASC";//เป็นการสร้างเงื่อนไขในการที่จะเลือกทั้งหมด
$result = mysql_query($sql) or die(mysql_error());
//echo $sql;echo mysql_error();
while($row=mysql_fetch_assoc($result)){
?>
<option value="<?php echo $row['user_id']; ?>"><?php echo $row['username']; ?></option>
<?php }?>
</select>
<input type="text" name="carlender">
<input type="button" name="Submit" value="ปฎิทิน" onClick="showCalendar('carlender','YYYY-MM-DD')"> <input type="submit" value="Search">
</th>
</tr>
</table>
<div align="center">
</div>
</form>
<?
if($_GET["carlender"] != "")
{
//Search By Name or Email
//$strSQL = "SELECT * FROM µÒÃÒ§ WHERE (ÃËÑÊ ='{$_SESSION['admin_array']['user_id']}'
//and Çѹ·Õè = '$_GET[carlender]') ";
$strSQL = "SELECT * FROM r_report WHERE carlender = '$_GET[carlender]' ";
if($_GET['user_id']!='0'){
$strSQL .=" and username='$_GET[user_id]'";
}
$objQuery = mysql_query($strSQL) ;
echo mysql_error();
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 3; // 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 .=" LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
?>
<form name="dataform" id="dataform">
<table width="788" border="1" align="center">
<tr bgcolor="#DAF9FC">
<th width="51"><span class="style1">ลำดับ</span></th>
<th width="93"><div align="center" class="style1">รหัสบุคลากร</div></th>
<th width="185"> <div align="center" class="style1">ชื่อบุคลากร</div></th>
<th width="277"> <div align="center" class="style1">รายงานการปฎิบัติงาน</div></th>
<th width="148"> <div align="center" class="style1">วันที่</div></th>
</tr>
<?
$i=$Page_Start ;
while($objResult = mysql_fetch_array($objQuery))
{
$i++;
list($y,$m,$d)=explode("-",$objResult[carlender]);
$sql = "SELECT user_id,username FROM personal where user_id='$objResult[username]' ";
$result = mysql_query($sql) or die(mysql_error());
$row=mysql_fetch_assoc($result);//เอาข้อมูลมาใส่โดยดึงมาแค่แร็กคอดเดียว
?>
<tr>
<td><div align="center"><?php echo $i; ?></div></td>
<td><div align="center"><?=$objResult["username"];?></div></td>
<td><? echo $row["username"];?></td>
<td><?=$objResult["report"];?></td>
<td><div align="center">
<?php echo $d,'-',$m,'-',($y+543);?>
</div></td>
</tr>
<?
}
?>
</table>
<div align="center">Total
<?= $Num_Rows;?>
Record :
<?=$Num_Pages;?>
Page :
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&user_id=$_GET[user_id]&carlender=$_GET[carlender]'><< Back</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&user_id=$_GET[user_id]&carlender=$_GET[carlender]'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&&user_id=$_GET[user_id]&carlender=$_GET[carlender]'>Next>></a> ";
}
//echo"5555555" ;
}
?>
</div>
</form>
<br>
</body>
</html>
|
 |
 |
 |
 |
Date :
2009-07-25 10:40:57 |
By :
preapo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตะเองก้อทำแบบว่ารับข้อมูลไปแสดงผลอีกหน้าอ่ะเอาอันนี้ไปไว้อีกหน้านึง
<?
if($_GET["carlender"] != "")
{
//Search By Name or Email
//$strSQL = "SELECT * FROM µÒÃÒ§ WHERE (ÃËÑÊ ='{$_SESSION['admin_array']['user_id']}'
//and Çѹ·Õè = '$_GET[carlender]') ";
$strSQL = "SELECT * FROM r_report WHERE carlender = '$_GET[carlender]' ";
if($_GET['user_id']!='0'){
$strSQL .=" and username='$_GET[user_id]'";
}
$objQuery = mysql_query($strSQL) ;
echo mysql_error();
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 3; // 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 .=" LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
?>
<form name="dataform" id="dataform">
<table width="788" border="1" align="center">
<tr bgcolor="#DAF9FC">
<th width="51"><span class="style1">ลำดับ</span></th>
<th width="93"><div align="center" class="style1">รหัสบุคลากร</div></th>
<th width="185"> <div align="center" class="style1">ชื่อบุคลากร</div></th>
<th width="277"> <div align="center" class="style1">รายงานการปฎิบัติงาน</div></th>
<th width="148"> <div align="center" class="style1">วันที่</div></th>
</tr>
<?
$i=$Page_Start ;
while($objResult = mysql_fetch_array($objQuery))
{
$i++;
list($y,$m,$d)=explode("-",$objResult[carlender]);
$sql = "SELECT user_id,username FROM personal where user_id='$objResult[username]' ";
$result = mysql_query($sql) or die(mysql_error());
$row=mysql_fetch_assoc($result);//เอาข้อมูลมาใส่โดยดึงมาแค่แร็กคอดเดียว
?>
<tr>
<td><div align="center"><?php echo $i; ?></div></td>
<td><div align="center"><?=$objResult["username"];?></div></td>
<td><? echo $row["username"];?></td>
<td><?=$objResult["report"];?></td>
<td><div align="center">
<?php echo $d,'-',$m,'-',($y+543);?>
</div></td>
</tr>
<?
}
?>
</table>
<div align="center">Total
<?= $Num_Rows;?>
Record :
<?=$Num_Pages;?>
Page :
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&user_id=$_GET[user_id]&carlender=$_GET[carlender]'><< Back</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&user_id=$_GET[user_id]&carlender=$_GET[carlender]'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&&user_id=$_GET[user_id]&carlender=$_GET[carlender]'>Next>></a> ";
}
//echo"5555555" ;
}
?>
เสดแล้วก้อไปแก้ตรง form ที่รับข้อมูลอ่ะให้มานไปยังหน้าใหม่ค่ะ ลองดูนะค่ะ
|
 |
 |
 |
 |
Date :
2009-07-25 13:03:02 |
By :
gummezaka |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|