|
|
|
Php มาสามารถคำนวณรวมค่า Sum ให้เราได้ไหมครับ อยากให้มันรวมค่าให้ ในด้านล่าง |
|
|
|
|
|
|
|
ตามภาพผมอยากให้ ราคา กับ จำนวนแต้ม มันรวมกันด้านล่าง สามารถทำได้ไหมครับ ขอบคุณครับ
Code (PHP)
<?php require_once('Connections/MyConnect.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$colname_Searchpoint = "-1";
if (isset($_GET['no'])) {
$colname_Searchpoint = $_GET['no'];
}
mysql_select_db($database_MyConnect, $MyConnect);
$query_Searchpoint = sprintf("SELECT * FROM q_foraddpoint WHERE `no` LIKE %s", GetSQLValueString($colname_Searchpoint, "int"));
$Searchpoint = mysql_query($query_Searchpoint, $MyConnect) or die(mysql_error());
$row_Searchpoint = mysql_fetch_assoc($Searchpoint);
$totalRows_Searchpoint = mysql_num_rows($Searchpoint);
$colname_Recordset1 = "-1";
if (isset($_POST['no'])) {
$colname_Recordset1 = $_POST['no'];
}
mysql_select_db($database_MyConnect, $MyConnect);
$query_Recordset1 = sprintf("SELECT * FROM q_foraddpoint WHERE `no` = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $MyConnect) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
$colname_Recordset2 = "-1";
if (isset($_POST['word'])) {
$colname_Recordset2 = $_POST['word'];
}
mysql_select_db($database_MyConnect, $MyConnect);
$query_Recordset2 = sprintf("SELECT * FROM q_foraddpoint WHERE `no` like %s", GetSQLValueString("%" . $colname_Recordset2 . "%", "text"));
$Recordset2 = mysql_query($query_Recordset2, $MyConnect) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
?>
<!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>
</head>
<body>
<div align="center">
<table border="1">
<tr>
<td><div align="center">ร้านค้า</div></td>
<td><div align="center">รหัสสมาชิก</div></td>
<td><div align="center">ชื่อ</div></td>
<td><div align="center">นามสกุล</div></td>
<td><div align="center">สินค้าที่ซื้อ</div></td>
<td><div align="center">ขนาดสินค้า</div></td>
<td><div align="center">จำนวน</div></td>
<td><div align="center">ราคา</div></td>
<td><div align="center">จำนวนแต้มที่ได้</div></td>
<td><div align="center">วันที่ซื้อ</div></td>
<td><div align="center">วันที่บันทึกข้อมูล</div></td>
<td><div align="center">พนักงานคีย์ข้อมูล</div></td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset2['shop']; ?></td>
<td><?php echo $row_Recordset2['no']; ?></td>
<td><?php echo $row_Recordset2['name']; ?></td>
<td><?php echo $row_Recordset2['lastname']; ?></td>
<td><?php echo $row_Recordset2['product']; ?></td>
<td><?php echo $row_Recordset2['size']; ?></td>
<td><?php echo $row_Recordset2['quantity']; ?></td>
<td><?php echo $row_Recordset2['price']; ?></td>
<td><?php echo $row_Recordset2['score']; ?></td>
<td><?php echo $row_Recordset2['buydate']; ?></td>
<td><?php echo $row_Recordset2['savedate']; ?></td>
<td><?php echo $row_Recordset2['employadd']; ?></td>
</tr>
<?php } while ($row_Recordset2 = mysql_fetch_assoc($Recordset2)); ?>
</table>
</div>
</body>
</html>
<?php
mysql_free_result($Searchpoint);
mysql_free_result($Recordset1);
mysql_free_result($Recordset2);
?>
Tag : PHP, MySQL, JavaScript, Ajax, jQuery
|
|
|
|
|
|
Date :
2015-10-16 12:41:38 |
By :
Jaruwatth |
View :
1123 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
กำหนด buffer เพื่อเก็บค่าผลรวมต่างๆที่บันทัด 088
<?php do { ?>
เพิ่มตัวแปร
Code (PHP)
<?php
$buffer1 = 0; $buffer2 = 0;
do{
$buffer1 += $value1;
$buffer2 += $value2;
?>
<tr><td>...</td></tr>
<?php
}
?>
<tr><td>ผลรวม.....</td></tr>
|
|
|
|
|
Date :
2015-10-17 05:37:27 |
By :
NewbiePHP |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|