|
|
|
การแบ่งหน้าแสดง มันติดอะไรไม่รู้ช่วยดูให้หน่อยค่ะ โค้ดตามข้างล่างเนี้ยค่ะ |
|
|
|
|
|
|
|
<? include('sess.php'); ?>
<!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>
<script language="javascript">
function Conf()
{
if (confirm("Do you want to delete ?") ==true)
{
return true;
}
return false;
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title></title>
<meta name="keywords" content="Business Website, free templates, website templates, 3-column layout, CSS, XHTML" />
<meta name="description" content="Business Website, 3-column layout, free CSS template from templatemo.com" />
<link href="templatemo_style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style3 {color: #FFFFFF}
.style4 {color: #000000}
.style5 {font-size: 14px; font-weight: bold; }
-->
</style>
</head>
<body>
<div id="templatemo_container">
<div id="templatemo_header">
<div id="logosection">
<div class="sitelogo"></div>
<div class="sitename">
<span></span> </div>
</div>
<div id="header"></div>
</div>
<div id="templatemo_menu">
<div id="search">
</div>
<div id="menu">
<ul>
<li><a href="index_ESparts.php">หน้าหลัก</a></li>
<li><a href="add_Ds.php" class="current">เพิ่มข้อมูล</a></li>
</ul>
</div>
</div>
<!-- start of content -->
<div id="templatemo_content">
<!-- start of left column -->
<div id="templatemo_left_column">
<div id="leftcolumn_box01">
<div class="leftcolumn_box01_top">
<h2>ยินดีต้อนรับ</h2>
</div>
<div class="leftcolumn_box01_bottom">
<div><h2><span class="style4">คุณ</span><?php echo "$name $lname";?></h2>
</div>
<p><a href="logout.php">Logout</a></p>
</div>
</div>
<div id="leftcolumn_box02">
<div class="leftcolumn_box02_top">
<h1 class="style3">การจัดการข้อมูล</h1>
</div>
<ul>
<li><a href="add_Ds.php"target="_parent" class="style5">การจัดการข้อมูลอะไหล่</a></li>
<li><a href="add_product_r.php"target="_parent" class="style5">การจัดการข้อมูลเบิกอะไหล่</a></li>
<li><a href="add_approve.php"target="_parent" class="button style5">การจัดการข้อมูลขออนุมัติซื้อ</a></li>
<li><a href="add_Dunit.php"target="_parent" class="button style5">จัดการข้อมูลหน่วยนับ</a></li>
<li><a href="add_Dca.php"target="_parent" class="button style5">จัดการข้อมูลประเภทอะไหล่</a></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
<div id="imagebutton">
<embed src="http://www.siaminfobiz.com/Icons/Calendar/kal16.swf" width="180" height="250" wmode="transparent" type="application/x-shockwave-flash"></embed> </div>
</div>
<!-- end of left column -->
<!-- start of middle column -->
<div id="templatemo_middle_column">
<form id="form1" name="form1" method="post" >
<table width="396" height="190" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<th width="434" height="40" scope="col"><img src="images/images/p_01.gif" width="400" height="40" /></th>
</tr>
<tr align="center">
<td height="148" align="center" valign="middle"><table width="340" height="112" border="0" cellpadding="0" cellspacing="0">
<tr>
<th width="141" height="34" align="right" valign="middle" scope="col">เลือกประเภท:</th>
<td width="199" align="left" >
<select name="e" size="1">
<option value="spare_id" >รหัสอะไหล่</option>
<option value="spare_name" >ชื่ออะไหล่</option>
<option value="category_name">ประเภทอะไหล่</option>
</select></td>
</tr>
<tr>
<td height="35" align="right"><strong>ค้นหา:</strong></td>
<td align="left"><span class="style29">
<input name="search" type="text" class="textfield" value="<?=$_POST['search']?>" />
</span></td>
</tr>
<tr>
<td height="30" align="right"> </td>
<td align="left" valign="middle"><input type="submit" name="Search" id="button" value="Search" /></td>
</tr>
</table> </td>
</tr>
</table>
</form> </td>
<p>
<?
// เชื่อมต่อฐานข้อมูล
include('connect.php');
if($_POST['Search'])
{
if($_GET["search"] != "")
{
$search=$_POST['search'];
$sql=" SELECT
spareparts.category_id,
category.category_name,
category.category_id,
spareparts.spare_id,
spareparts.spare_name,
spareparts.number,
spareparts.unit
FROM
spareparts
Inner Join category ON category.category_id = spareparts.category_id Where $e like '%$search%'";
// $sql="select * from spareparts Where $e like '%$search%' "; // คำสั่งค้นหา
}else{
$sql = "SELECT
spareparts.category_id,
category.category_name,
category.category_id,
spareparts.spare_id,
spareparts.spare_name,
spareparts.number,
spareparts.unit
FROM
spareparts
Inner Join category ON category.category_id = spareparts.category_id
"; //คำสั่ง SQL เพื่อการแสดงผล
}
$AllNisit = mysql_query ($dbname, $sql)or die(mysql_error());
$totalRows_AllNisit = mysql_num_rows($AllNisit);
$Num_Rows = mysql_num_rows( $dbquery);
//echo $sql;
$Per_Page = 2; // 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;
}
$sql .=" ORDER BY spare_id DESC LIMIT $Page_Start , $Per_Page";
$AllNisit = mysql_query($sql );
$u=$Page_Start;
if ($totalRows_AllNisit > 0) { // Show if recordset not empty ?>
<table width="663" height="56" border="1" cellpadding="2" cellspacing="2" bgcolor="#F1CDAE">
<tr>
<td width="44" bgcolor="#66CC00"><div align="center">ลำดับที่</div></td>
<td width="66" bgcolor="#66CC00"><div align="center">รหัสอะไหล่</div></td>
<td width="93" bgcolor="#66CC00"><div align="center">ประเภทอะไหล่</div></td>
<td width="127" bgcolor="#66CC00"><div align="center">ชื่ออะไหล่</div></td>
<td width="51" bgcolor="#66CC00"><div align="center">จำนวน</div></td>
<td width="57" bgcolor="#66CC00"><div align="center">หน่วยนับ</div></td>
<td width="38" height="24" bgcolor="#66CC00"><div align="center">ดู</div></td>
<td width="53" height="24" bgcolor="#66CC00"><div align="center">แก้ไข</div></td>
<td width="44" height="24" bgcolor="#66CC00"><div align="center">ลบ</div></td>
</tr>
<?php while ($row_AllNisit = mysql_fetch_assoc($AllNisit))
{ ?> <tr>
<td><div align="center"><? echo $u++;?></td>
<td><div align="center"><?=$row_AllNisit['spare_id']?></td>
<td><div align="center"><?=$row_AllNisit['category_name']?></td>
<td><div align="center"><?=$row_AllNisit['spare_name']?></td>
<td><div align="center"><?=$row_AllNisit['number']?></td>
<td><div align="center"><?=$row_AllNisit['unit']?></td>
<td> <div align="center"> <a href="show_s.php?spare_id=<?=$row_AllNisit[spare_id]?>">ดู</a></td>
<td> <div align="center"> <a href="update_Ds.php?spare_id=<?=$row_AllNisit[spare_id]?>">แก้ไข</a></td>
<td><div align="center"><a href="delete_s.php?spare_id=<?=$row_AllNisit[spare_id]?>" onclick="return Conf()";>ลบ</a></td>
</tr>
<?php } ?>
</table>
Total <?php echo $Num_Rows;?> Record : <?php echo $Num_Pages;?> Page :
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtKeyword=$_GET[txtKeyword]'><< Back</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtKeyword=$_GET[txtKeyword]'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtKeyword=$_GET[txtKeyword]'>Next>></a> ";
}
}}
?>
</table width="830" height="46" align="right" valign="baseline"></p>
<tr><td colspan="3"> </td>
</tr>
<tr>
<td> </td>
<td colspan="3" align="left" valign="middle">
</table>
<p></p>
<br />
</div>
<p>
<!-- end of middle column -->
</p>
<p>
<!-- start of right column -->
<!-- end of right column -->
</p>
</div>
</div>
</body>
</html>
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2011-07-07 17:35:02 |
By :
มาม่า |
View :
803 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เอา error มาดูดีกว่าครับ ง่ายกว่า
|
|
|
|
|
Date :
2011-07-07 18:14:37 |
By :
slurpee55555 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คือมันไม่ขึ้นเลยค่ะ และไม่มีerror
|
|
|
|
|
Date :
2011-07-07 18:58:41 |
By :
siriampha |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลอง ลบ ชุดนี้ออกครับ แล้วการรับค่าเปลี่ยนให้เป็น GET ครับ
if($_POST['Search'])
{
}
|
ประวัติการแก้ไข 2011-07-07 22:12:00
|
|
|
|
Date :
2011-07-07 22:11:24 |
By :
slurpee55555 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลบแล้วค่ะ ก็ออกปกติค่ะ พอจะทราบไหมค่ะว่าต้องแบ่งหน้ายังไง
<form id="form1" name="form1" method="GET" >
<table width="396" height="190" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<th width="434" height="40" scope="col"><img src="images/images/p_01.gif" width="400" height="40" /></th>
</tr>
<tr align="center">
<td height="148" align="center" valign="middle"><table width="340" height="112" border="0" cellpadding="0" cellspacing="0">
<tr>
<th width="141" height="34" align="right" valign="middle" scope="col">เลือกประเภท:</th>
<td width="199" align="left" >
<select name="e" size="1">
<option value="spare_id" >รหัสอะไหล่</option>
<option value="spare_name" >ชื่ออะไหล่</option>
<option value="category_name">ประเภทอะไหล่</option>
</select></td>
</tr>
<tr>
<td height="35" align="right"><strong>ค้นหา:</strong></td>
<td align="left"><span class="style29">
<input name="search" type="text" class="textfield" value="<?=$_POST['search']?>" />
</span></td>
</tr>
<tr>
<td height="30" align="right"> </td>
<td align="left" valign="middle"><input type="submit" name="Search" id="button" value="Search" /></td>
</tr>
</table> </td>
</tr>
</table>
</form> </td>
<p>
<table width="663" height="56" border="1" cellpadding="2" cellspacing="2" bgcolor="#F1CDAE">
<tr>
<td width="44" bgcolor="#66CC00"><div align="center">ลำดับที่</div></td>
<td width="66" bgcolor="#66CC00"><div align="center">รหัสอะไหล่</div></td>
<td width="93" bgcolor="#66CC00"><div align="center">ประเภทอะไหล่</div></td>
<td width="127" bgcolor="#66CC00"><div align="center">ชื่ออะไหล่</div></td>
<td width="51" bgcolor="#66CC00"><div align="center">จำนวน</div></td>
<td width="57" bgcolor="#66CC00"><div align="center">หน่วยนับ</div></td>
<td width="38" height="24" bgcolor="#66CC00"><div align="center">ดู</div></td>
<td width="53" height="24" bgcolor="#66CC00"><div align="center">แก้ไข</div></td>
<td width="44" height="24" bgcolor="#66CC00"><div align="center">ลบ</div></td>
</tr>
<?
// เชื่อมต่อฐานข้อมูล
include('connect.php');
if($_GET['Search'])
{
$search=$_POST['search'];
$sql=" SELECT
spareparts.category_id,
category.category_name,
category.category_id,
spareparts.spare_id,
spareparts.spare_name,
spareparts.number,
spareparts.unit
FROM
spareparts
Inner Join category ON category.category_id = spareparts.category_id Where $e like '%$search%'";
// $sql="select * from spareparts Where $e like '%$search%' "; // คำสั่งค้นหา
}else{
$sql = "SELECT
spareparts.category_id,
category.category_name,
category.category_id,
spareparts.spare_id,
spareparts.spare_name,
spareparts.number,
spareparts.unit
FROM
spareparts
Inner Join category ON category.category_id = spareparts.category_id
"; //คำสั่ง SQL เพื่อการแสดงผล
}
// เลือกฐานข้อมูล
$dbquery = mysql_db_query($dbname, $sql);
//echo $sql;
$i=1;
while ($result = mysql_fetch_array($dbquery)) //วนลูปแสดงผล
{
?>
<tr>
<td><div align="center"><? echo $i;?></td>
<td><div align="center"><?=$result['spare_id']?></td>
<td><div align="center"><?=$result['category_name']?></td>
<td><div align="center"><?=$result['spare_name']?></td>
<td><div align="center"><?=$result['number']?></td>
<td><div align="center"><?=$result['unit']?></td>
<td> <div align="center"> <a href="show_s.php?spare_id=<?=$result[spare_id]?>">ดู</a></td>
<td> <div align="center"> <a href="update_Ds.php?spare_id=<?=$result[spare_id]?>">แก้ไข</a></td>
<td><div align="center"><a href="delete_s.php?spare_id=<?=$result[spare_id]?>" onclick="return Conf()";>ลบ</a></td>
</tr>
<?
$i++;
}
?>
|
|
|
|
|
Date :
2011-07-08 00:21:51 |
By :
มาม่า |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|