อยากให้หน้าเวปที่แสดงข้อมูล มันคำนวณ รวมข้อมูลให้ครับ

ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา อยากให้หน้าเวปที่แสดงข้อมูล มันคำนวณ รวมข้อมูลให้ครับ

อยากให้หน้าเวปที่แสดงข้อมูล มันคำนวณ รวมข้อมูลให้ครับ


อยากให้มีการรวมคะแนนและราคา ด้านล่างตารางครับ

<?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);
?>
 


Jaruwat 114.109.111.xxx 16-10-2015 12:48:07

คำแนะนำ และการใช้งาน

สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก


  • ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
  • เปลี่ยน


    ( หรือ เข้าใช้งานผ่าน Social Login )

 ความคิดเห็นที่ 1
สร้างตัวแปรมาตัวหนึ่งไว้เก็บค่ารวม แล้วก็บวกค่าเพิ่มปกติ
$total=0;
while($ssss){
   $total+=$ssss['dddd'];
}


ninenik 180.183.45.xxx 16-10-2015






เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ