|
|
|
อยากทราบโค๊ด ราคารวมจะใส่ยังไง มือใหม่จริงๆๆ ครับผม |
|
|
|
|
|
|
|
Code (PHP)
<?php require_once('Connections/arunyik.php'); ?>
<?php
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_Rs_sup = 10;
$pageNum_Rs_sup = 0;
if (isset($_GET['pageNum_Rs_sup'])) {
$pageNum_Rs_sup = $_GET['pageNum_Rs_sup'];
}
$startRow_Rs_sup = $pageNum_Rs_sup * $maxRows_Rs_sup;
mysql_select_db($database_arunyik, $arunyik);
$query_Rs_sup = "SELECT * FROM supplies, suptype, personnel WHERE supplies.p_id=personnel.p_id AND supplies.suptype_id=suptype.suptype_id ORDER BY supplies.s_id DESC";
$query_limit_Rs_sup = sprintf("%s LIMIT %d, %d", $query_Rs_sup, $startRow_Rs_sup, $maxRows_Rs_sup);
$Rs_sup = mysql_query($query_limit_Rs_sup, $arunyik) or die(mysql_error());
$row_Rs_sup = mysql_fetch_assoc($Rs_sup);
if (isset($_GET['totalRows_Rs_sup'])) {
$totalRows_Rs_sup = $_GET['totalRows_Rs_sup'];
} else {
$all_Rs_sup = mysql_query($query_Rs_sup);
$totalRows_Rs_sup = mysql_num_rows($all_Rs_sup);
}
$totalPages_Rs_sup = ceil($totalRows_Rs_sup/$maxRows_Rs_sup)-1;
$queryString_Rs_sup = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_Rs_sup") == false &&
stristr($param, "totalRows_Rs_sup") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_Rs_sup = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_Rs_sup = sprintf("&totalRows_Rs_sup=%d%s", $totalRows_Rs_sup, $queryString_Rs_sup);
?><!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 {
font-size: 36px;
font-weight: bold;
}
-->
</style>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<p align="center" class="style1">รายการวัสดุ เบิก-จ่าย </p>
<table width="965" border="0" align="center">
<tr>
<td width="90" bgcolor="#CCCCCC">รหัส</td>
<td width="111" bgcolor="#CCCCCC">ชื่อวัสดุ</td>
<td width="101" bgcolor="#CCCCCC">ขนาด</td>
<td width="100" bgcolor="#CCCCCC">หน่วยนับ</td>
<td width="109" bgcolor="#CCCCCC">ราคาต่อ/หน่วย</td>
<td width="63" bgcolor="#CCCCCC">ราคารวม</td>
<td width="159" bgcolor="#CCCCCC">พนักงานเบิก</td>
<td width="124" bgcolor="#CCCCCC">จำนวนเบิก</td>
<td width="81" bgcolor="#CCCCCC"> </td>
</tr>
<?php do { ?>
<tr>
<td height="26" bgcolor="#F0F0F0"><?php echo $row_Rs_sup['s_id']; ?></td>
<td bgcolor="#F0F0F0"><?php echo $row_Rs_sup['s_name']; ?></td>
<td bgcolor="#F0F0F0"><?php echo $row_Rs_sup['s_size']; ?></td>
<td bgcolor="#F0F0F0"><?php echo $row_Rs_sup['s_unit']; ?></td>
<td bgcolor="#F0F0F0"><?php echo $row_Rs_sup['s_price']; ?></td>
<td bgcolor="#F0F0F0"><span class="text044">
</span></td>
<td bgcolor="#F0F0F0"><label>
<select name="select">
<option value="0">กรุณาเลือกชื่อพนักงาน</option>
<?php
do {
?>
<option value="<?php echo $row_Rs_sup['p_id']?>"><?php echo $row_Rs_sup['p_fname']?></option>
<?php
} while ($row_Rs_sup = mysql_fetch_assoc($Rs_sup));
$rows = mysql_num_rows($Rs_sup);
if($rows > 0) {
mysql_data_seek($Rs_sup, 0);
$row_Rs_sup = mysql_fetch_assoc($Rs_sup);
}
?>
</select>
</label></td>
<td bgcolor="#F0F0F0"><label>
<input name="textfield" type="text" size="5" maxlength="7" />
<input type="submit" name="Submit" value="ตกลง" />
</label></td>
<td bgcolor="#F0F0F0"><label>
<input type="submit" name="Submit2" value="ยืนยันเบิก" />
</label></td>
</tr>
<?php } while ($row_Rs_sup = mysql_fetch_assoc($Rs_sup)); ?>
<tr>
<td colspan="9"><div align="center">
<table border="0" width="50%" align="center">
<tr>
<td width="23%" align="center"><?php if ($pageNum_Rs_sup > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Rs_sup=%d%s", $currentPage, 0, $queryString_Rs_sup); ?>">First</a>
<?php } // Show if not first page ?>
</td>
<td width="31%" align="center"><?php if ($pageNum_Rs_sup > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Rs_sup=%d%s", $currentPage, max(0, $pageNum_Rs_sup - 1), $queryString_Rs_sup); ?>">Previous</a>
<?php } // Show if not first page ?>
</td>
<td width="23%" align="center"><?php if ($pageNum_Rs_sup < $totalPages_Rs_sup) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_Rs_sup=%d%s", $currentPage, min($totalPages_Rs_sup, $pageNum_Rs_sup + 1), $queryString_Rs_sup); ?>">Next</a>
<?php } // Show if not last page ?>
</td>
<td width="23%" align="center"><?php if ($pageNum_Rs_sup < $totalPages_Rs_sup) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_Rs_sup=%d%s", $currentPage, $totalPages_Rs_sup, $queryString_Rs_sup); ?>">Last</a>
<?php } // Show if not last page ?>
</td>
</tr>
</table>
</div></td>
</tr>
</table>
<p> </p>
</form>
</body>
</html>
<?php
mysql_free_result($Rs_sup);
?>
Tag : PHP, MySQL, CakePHP
|
|
|
|
|
|
Date :
2013-02-11 09:50:55 |
By :
natt3021 |
View :
725 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอดู Loop เฉพาะส่วนคำนวนราคาครับ
|
|
|
|
|
Date :
2013-02-11 11:26:10 |
By :
Ex-[S]i[L]e[N]t |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|