|
|
|
ช่วยใส่โค๊ดการเรียงอันดับให้ให้หน่อยครับ ตามรูปด้่านในเลยครับ |
|
|
|
|
|
|
|
Code (PHP)
<?php
<?php require_once('Connections/mydatabase.php'); ?>
<?php
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_Recordset1 = 20;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
mysql_select_db($database_mydatabase, $mydatabase);
$query_Recordset1 = "SELECT product.ProductName, product.Price, product.Num, product.unit, product.`size`, product.ProductID, product2.Number, product2.M, product2.Y FROM product2, product WHERE product2.ID=product.ProductID AND product2.M='$M' AND product2.Y='$Y'";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $mydatabase) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
$queryString_Recordset1 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_Recordset1") == false &&
stristr($param, "totalRows_Recordset1") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s", $totalRows_Recordset1, $queryString_Recordset1);
?>
<!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>ออกรายงานสรุปยอดคงเหลือ</title>
<style type="text/css">
<!--
.style1 {color: #FF0000}
.style3 {color: #009900}
-->
</style>
</head>
<?
$i=0;
while($detail=mysql_fetch_array($select))
$i++;{
echo $i;
}
?>
<body>
<form id="form1" name="form1" method="post" action="report.php">
<p></p>
<table width="1122" border="1" align="center" cellspacing="0" bordercolor="#000000">
<tr>
<td colspan="7" align="center">รายการวัสดุ-อุปกรณ์ประปา คงเหลือ ณ เดือน
<label><?php echo $row_Recordset1['M']; ?> <?php echo $row_Recordset1['Y']; ?></label></td>
</tr>
<tr>
<td width="193" align="center">ลำดับที่</td>
<td width="193" align="center">รายการ</td>
<td width="162" align="center">ขนาด</td>
<td width="139" align="center">จำนวนเบิก</td>
<td width="110" align="center">หน่วย</td>
<td width="189" align="center">จำนวนคงเหลือ</td>
<td width="106" align="center">หมายเหตุ</td>
</tr>
<tr>
<td align="center"></td>
<td align="center"><?php echo $row_Recordset1['ProductName']; ?></td>
<td align="center"><?php echo $row_Recordset1['size']; ?></td>
<td align="center" bgcolor="#CCCCCC"><?php echo $row_Recordset1['Number']; ?></td>
<td align="center"><?php echo $row_Recordset1['unit']; ?></td>
<td align="center" bgcolor="#CCCCCC"><?php if ($row_Recordset1["Num"]<=0) {?>
<span class="style1"><?php echo $row_Recordset1['Num']; ?></span>
<? }else {?>
<span class="style3"><?php echo $row_Recordset1['Num']; ?></span>
<? } ?> </td>
<td width="106" align="center"> </td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
<div align="center">
<p>จำนวนทั้งหมด <?php echo $totalRows_Recordset1 ?> รายการ <table border="0" width="50%" align="center">
<tr>
<td width="23%" align="center"><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, 0, $queryString_Recordset1); ?>">First</a>
<?php } // Show if not first page ?>
</td>
<td width="31%" align="center"><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, max(0, $pageNum_Recordset1 - 1), $queryString_Recordset1); ?>">Previous</a>
<?php } // Show if not first page ?>
</td>
<td width="23%" align="center"><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, min($totalPages_Recordset1, $pageNum_Recordset1 + 1), $queryString_Recordset1); ?>">Next</a>
<?php } // Show if not last page ?>
</td>
<td width="23%" align="center"><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, $totalPages_Recordset1, $queryString_Recordset1); ?>">Last</a>
<?php } // Show if not last page ?>
</td>
</tr>
</table>
<p>
<label></label>
<input type="button" name="button" id="button" value="กลับ" onclick="window.location='chaos_report2.php'"/>
<input type="button" name="button" id="button" value="Print" onclick="print();"><style type="text/css" media="print">
input{
display:none;
}
</style>
</p>
</div>
</form>
<p align="center"> </p>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
Tag : PHP, MySQL
|
ประวัติการแก้ไข 2013-03-07 18:39:17
|
|
|
|
|
Date :
2013-03-07 17:33:37 |
By :
natt3021 |
View :
681 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ในฐานข้อมูล product มี product_id อยู่ไหมครับ ถ้ามี product_id productname ก็จะมีลำดับอยู่แล้ว
product_id ใช้เป็น int+auto_increment
แล้วก็เพิ่มตรงส่วนนี้
$query_Recordset1 = "SELECT product.Product_id
ถ้าไม่ตรงก็ขออภัยครับ
|
|
|
|
|
Date :
2013-03-07 17:47:25 |
By :
puldool |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_Recordset1 = 20;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
mysql_select_db($database_mydatabase, $mydatabase);
$query_Recordset1 = "SELECT product.ProductName, product.Price, product.Num, product.unit, product.`size`, product.ProductID, product2.Number, product2.M, product2.Y FROM product2, product WHERE product2.ID=product.ProductID AND product2.M='$M' AND product2.Y='$Y'";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $mydatabase) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
$queryString_Recordset1 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_Recordset1") == false &&
stristr($param, "totalRows_Recordset1") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s", $totalRows_Recordset1, $queryString_Recordset1);
?><!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>ออกรายงานสรุปยอดคงเหลือ</title>
<style type="text/css">
<!--
.style1 {color: #FF0000}
.style3 {color: #009900}
-->
</style>
</head>
<body>
<form id="form1" name="form1" method="post" action="report.php">
<p></p>
<table width="1122" border="1" align="center" cellspacing="0" bordercolor="#000000">
<tr>
<td colspan="7" align="center">รายการวัสดุ-อุปกรณ์ประปา คงเหลือ ณ เดือน
<label><?php echo $row_Recordset1['M']; ?> <?php echo $row_Recordset1['Y']; ?></label></td>
</tr>
<tr>
<td width="193" align="center">ลำดับที่</td>
<td width="193" align="center">รายการ</td>
<td width="162" align="center">ขนาด</td>
<td width="139" align="center">จำนวนเบิก</td>
<td width="110" align="center">หน่วย</td>
<td width="189" align="center">จำนวนคงเหลือ</td>
<td width="106" align="center">หมายเหตุ</td>
</tr>
<?php
$i=0; // กำนหดลำดับเริ่มต้นที่ 0
do {
$i++; // เมื่อ do ให้ +1
?>
<tr>
<td align="center" bgcolor="#FF0000"><?=$i;?></td>
<td align="center"><?php echo $row_Recordset1['ProductName']; ?></td>
<td align="center"><?php echo $row_Recordset1['size']; ?></td>
<td align="center" bgcolor="#CCCCCC"><?php echo $row_Recordset1['Number']; ?></td>
<td align="center"><?php echo $row_Recordset1['unit']; ?></td>
<td align="center" bgcolor="#CCCCCC"><?php if ($row_Recordset1["Num"]<=0) {?>
<span class="style1"><?php echo $row_Recordset1['Num']; ?></span>
<? }else {?>
<span class="style3"><?php echo $row_Recordset1['Num']; ?></span>
<? } ?> </td>
<td width="106" align="center"> </td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
<div align="center">
<p>จำนวนทั้งหมด <?php echo $totalRows_Recordset1 ?> รายการ <table border="0" width="50%" align="center">
<tr>
<td width="23%" align="center"><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, 0, $queryString_Recordset1); ?>">First</a>
<?php } // Show if not first page ?>
</td>
<td width="31%" align="center"><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, max(0, $pageNum_Recordset1 - 1), $queryString_Recordset1); ?>">Previous</a>
<?php } // Show if not first page ?>
</td>
<td width="23%" align="center"><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, min($totalPages_Recordset1, $pageNum_Recordset1 + 1), $queryString_Recordset1); ?>">Next</a>
<?php } // Show if not last page ?>
</td>
<td width="23%" align="center"><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, $totalPages_Recordset1, $queryString_Recordset1); ?>">Last</a>
<?php } // Show if not last page ?>
</td>
</tr>
</table>
<script language="JavaScript">
function checknum(value,fields)
{
if(!check_number(value))
{
eval("document.all."+fields+".value='1';");
alert('?????????????');
}
}
function check_number(ch){
var len, digit;
if(ch == " "){
return false;
len=0;
}else{
len = ch.length;
}
for(var i=0 ; i<len ; i++)
{
digit = ch.charat(i)
if(digit >="0" && digit <="9"){
;
}else{
return false;
}
}
return true;
}
</script>
</p>
<p class="style59"> </p>
<p class="style59"> </p></td>
</p>
<p>
<label></label>
<input type="button" name="button" id="button" value="กลับ" onclick="window.location='chaos_report2.php'"/>
<input type="button" name="button" id="button" value="Print" onclick="print();"><style type="text/css" media="print">
input{
display:none;
}
</style>
</p>
</div>
</form>
<p align="center"> </p>
</body>
</html>
<?php
|
ประวัติการแก้ไข 2013-03-07 18:41:07
|
|
|
|
Date :
2013-03-07 18:01:24 |
By :
Ex-[S]i[L]e[N]t |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|