PHP Ionic Angularjs Phonegap AJAX Javascript CSS MySQL jQuery Forum

ช่วหน่อยครับ php

ช่วหน่อยครับ php
ผมได้นำผลรวมจากฐานข้อมูลออกมาโชว์เรียบร้อยแล้วครับ   แต่ตอนนี้ผมใช้คำสั่งค้นหาโดยที่ ผมอยากให้มันรวมค่าเฉพาะที่ผมค้นหาที่ดึงออกมาจกฐานข้อมูลผมอยากให้มันรวมเฉพาะที่ผมค้นหานะครับรบกวนด้วยนะครับตันจริงๆๆๆขอบพระคุณเป็นอย่างสูงครับ

<input name="sum1" type="text" id="sum1" size="5" 
   value="<?php $query = "SELECT * FROM bankrecycle ";
$query_run = mysql_query($query);
$sum1= 0;
while ($row_Recordset1['num1']= mysql_fetch_assoc ($query_run)) {
 
    $sum1+= $row_Recordset1['num1']['num1'];
}
echo $sum1; ?> "/>


โดย:  Soomsam77 IP: 122.154.245.xxx วันที่: 13-03-2015 เวลา: 11:51:27

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

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


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


  • ( หรือ สามารถทำการ สมัครสมาชิก และล็อกอิน ด้วย ปุ่ม Log in with Facebook ด้านล่าง )
 ความคิดเห็นที่ 4
<?php
$query = "SELECT SUM(num1) AS num1 FROM bankrecycle ";
$query_run = mysql_query($query);
if(mysql_num_rows($query_run) == 0){
$msg = "0";
} else {
$row_Recordset1= mysql_fetch_array ($query_run);
$msg = $row_Recordset1['num1'];
}
?>
<input name="sum1" type="text" id="sum1" size="5" value="<?= $msg ?>" /> 


โดย:  Ptcargo IP: 119.34.131.xxx วันที่: 24-03-2015 เวลา: 05:23:43
 ความคิดเห็นที่ 3
ไม่เคยใช้ dream เขียนโค้ดแบบ gen มาก่อน คงต้องลองประยุกต์เอาเอง 

โดย:  Ninenik IP: 171.96.90.xxx วันที่: 13-03-2015
 ความคิดเห็นที่ 2
คำสั้งค้นหาของผม
<form id="form2" name="form2" method="post" action="search2.php">
    <label for="word2"><strong>ค้นหาจากวันที่</strong>:</label>
    <input type="text" name="word2" id="word2" />
    <input type="submit" name="btnSearch" id="btnSearch" value="ค้นหา" />
  </form>
 
ครับ
<?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;

		
<?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_Recordset1 = "-1";
if (isset($_POST['word2'])) {
  $colname_Recordset1 = $_POST['word2'];
}
mysql_select_db($database_Myconnect, $Myconnect);
$query_Recordset1 = sprintf("SELECT * FROM bankrecycle WHERE date LIKE %s", GetSQLValueString("%" . $colname_Recordset1 . "%", "text"));
$Recordset1 = mysql_query($query_Recordset1, $Myconnect) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($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>Untitled Document</title>
<style type="text/css">
body,td,th {
	font-family: Tahoma, Geneva, sans-serif;
	font-size: 12px;
}
body {
	background-image: url(image/3.jpg);
}
</style>
<style type="text/css"> 

#printable { display: block; }

@media print 
{ 
     #non-printable { display: none; } 
     #printable { display: block; } 
} 

</style> 
</head>

<body>
<p><strong><center>ผลการค้นหาข้อมูล:</center></strong></p>
<table width="1200" height="98" border="1" align="center" bordercolor="#FFFF33">
  <tr>
    <td width="100" align="center" bgcolor="#00FF00"><strong>เลขที่บัญชี</strong></td>
    <td width="115" align="center" bgcolor="#00FF00"><strong>วัน/เดือน/ปี</strong></td>
    <td width="149" align="center" bgcolor="#00FF00"><strong>ชื่อ-นามสกุล</strong></td>
    <td colspan="4" align="center" valign="middle" bgcolor="#00FF00"><strong>พลาสติก</strong></td>
    <td colspan="6" align="center" bgcolor="#00FF00"><strong>โลหะ</strong></td>
    <td colspan="4" align="center" bgcolor="#00FF00"><strong>กระดาษ</strong></td>
    <td width="118" align="center" bgcolor="#00FF00"><strong>ขวดแก้ว/กก.</strong></td>
    <td width="109" align="center" bgcolor="#00FF00"><strong>รวม/กก.</strong></td>
  </tr>
  <?php do { ?>
    <tr>
      <td rowspan="2" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['id']; ?></td>
      <td rowspan="2" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['date']; ?></td>
      <td rowspan="2" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['name_last']; ?></td>
      <td width="146" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['list1']; ?></td>
      <td width="146" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['list2']; ?></td>
      <td width="146" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['list3']; ?></td>
      <td width="146" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['list4']; ?></td>
      <td width="146" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['l1']; ?></td>
      <td width="146" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['l2']; ?></td>
      <td width="146" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['l3']; ?></td>
      <td width="146" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['l4']; ?></td>
      <td width="146" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['l5']; ?></td>
      <td width="154" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['l6']; ?></td>
      <td width="154" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['s1']; ?></td>
      <td width="154" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['s2']; ?></td>
      <td width="154" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['s3']; ?></td>
      <td width="130" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['s4']; ?></td>
      <td rowspan="2" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['glass']; ?></td>
      <td rowspan="2" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['sum']; ?></td>
    </tr>
    <tr>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num1']; ?></td>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num2']; ?></td>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num3']; ?></td>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num4']; ?></td>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num5']; ?></td>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num6']; ?></td>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num7']; ?></td>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num8']; ?></td>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num9']; ?></td>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num10']; ?></td>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num11']; ?></td>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num12']; ?></td>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num13']; ?></td>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num14']; ?></td>
    </tr>
    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
 <table width="1200" height="66" border="1" align="center" bordercolor="#FFFF00">
    <tr>
      <td width="54" rowspan="2" align="center" bgcolor="#00FF00"><strong>รวม </strong></td>
      <td width="90" height="31" align="center" bgcolor="#00FF00"><strong>รวมกก./ใส</strong></td>
      <td width="87" align="center" bgcolor="#00FF00"><strong>รวมกก./ขาวขุ่น</strong></td>
      <td width="78" align="center" bgcolor="#00FF00"><strong>รวมกก./กรอบ</strong></td>
      <td width="82" align="center" bgcolor="#00FF00"><strong>รวมกก./รวม</strong></td>
      <td width="81" align="center" bgcolor="#00FF00"><strong>รวมกก./เหล็ก</strong></td>
      <td width="76" align="center" bgcolor="#00FF00"><strong>รวมกก./โลหะ</strong></td>
      <td width="99" align="center" bgcolor="#00FF00"><strong>รวมกก./อลูมิเนียม</strong></td>
      <td width="106" align="center" bgcolor="#00FF00"><strong>รวมกก./ทองเหลือง</strong></td>
      <td width="94" align="center" bgcolor="#00FF00"><strong>รวมกก./ทองแดง</strong></td>
      <td width="94" align="center" bgcolor="#00FF00"><strong>รวมกก./สังกะสี</strong></td>
      <td width="96" align="center" bgcolor="#00FF00"><strong>รวมกก.ขาวดำ</strong></td>
      <td width="136" align="center" bgcolor="#00FF00"><strong>รวมกก./ลัง</strong></td>
      <td width="158" align="center" bgcolor="#00FF00"><strong>รวมกก./รวม</strong></td>
      <td width="141" align="center" bgcolor="#00FF00"><strong>รวมกก./หนังสือพิมพ์</strong></td>
      <td width="120" align="center" bgcolor="#00FF00"><strong>รวมกก./ขวดแก้ว</strong></td>
      <td width="138" align="center" bgcolor="#00FF00"><strong>รวมยอดเงินทั้งหมด</strong></td>
    </tr>
    <tr>
      <td height="27" align="center" bgcolor="#FFFF66">
      <?php
$query = "SELECT * FROM bankrecycle ";
// ชุดคำสั่งสำหรับการค้นหา
if(isset($_POST['search_xxx'])){
	$query.=" WHERE xxx='".$_POST['search_xxx']."' ";
}
$query_run = mysql_query($query);
$sum1= 0;
while ($row_Recordset1['num1']= mysql_fetch_assoc ($query_run)) {
    $sum1+= $row_Recordset1['num1']['num1'];
}
?><input name="sum1" type="text" id="sum1" size="5" 
   value="<?=$sum1?>"/></td>

<td align="center" bgcolor="#FFFF66"><input name="sum2" type="text" id="sum2" 
      size="5" value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum2= 0;
while ($num2 = mysql_fetch_assoc ($query_run)) {

    $sum2 += $num2['num2'];
}
echo $sum2; ?>"/></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum3" type="text" id="sum3" size="5"
      value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum3= 0;
while ($num3 = mysql_fetch_assoc ($query_run)) {

    $sum3 += $num3['num3'];
}
echo $sum3; ?>"/></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum4" type="text" id="sum4" size="5"
      value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum4= 0;
while ($num4 = mysql_fetch_assoc ($query_run)) {

    $sum4 += $num4['num4'];
}
echo $sum4; ?>" /></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum5" type="text" id="sum5" size="5" 
      value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum5= 0;
while ($num5 = mysql_fetch_assoc ($query_run)) {

    $sum5 += $num5['num5'];
}
echo $sum5; ?>"/></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum6" type="text" id="sum6" size="5"
      value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum6= 0;
while ($num6 = mysql_fetch_assoc ($query_run)) {

    $sum6 += $num6['num6'];
}
echo $sum6; ?>" /></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum7" type="text" id="sum7" size="5" 
      value="<?php $query = "SELECT * FROM bankrecycle ";
$query_run = mysql_query($query);
$sum7= 0;
while ($num7 = mysql_fetch_assoc ($query_run)) {

    $sum7 += $num7['num7'];
}
echo $sum7; ?>"/></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum8" type="text" id="sum8" size="5" 
      value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum8= 0;
while ($num8 = mysql_fetch_assoc ($query_run)) {

    $sum8 += $num8['num8'];
}
echo $sum8; ?>"/></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum9" type="text" id="sum9" size="5" 
      value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum9= 0;
while ($num9 = mysql_fetch_assoc ($query_run)) {

    $sum9 += $num9['num9'];
}
echo $sum9; ?>"/></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum10" type="text" id="sum10" size="5" 
      value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum10= 0;
while ($num10 = mysql_fetch_assoc ($query_run)) {

    $sum10 += $num10['num10'];
}
echo $sum10; ?>"/></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum11" type="text" id="sum11" size="5" 
      value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum11= 0;
while ($num11 = mysql_fetch_assoc ($query_run)) {

    $sum11 += $num11['num11'];
}
echo $sum11; ?>"/></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum12" type="text" id="sum12" size="5" 
      value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum12= 0;
while ($num12 = mysql_fetch_assoc ($query_run)) {

    $sum12 += $num12['num12'];
}
echo $sum12; ?>"/></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum13" type="text" id="sum13" size="5" 
      value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum13= 0;
while ($num13 = mysql_fetch_assoc ($query_run)) {

    $sum13 += $num13['num13'];
}
echo $sum13; ?>"/></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum14" type="text" id="sum14" size="5" 
      value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum14= 0;
while ($num14 = mysql_fetch_assoc ($query_run)) {

    $sum14 += $num14['num14'];
}
echo $sum14; ?>"/></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum15" type="text" id="sum15" size="5" 
      value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum15= 0;
while ($glass = mysql_fetch_assoc ($query_run)) {

    $sum15 += $glass['glass'];
}
echo $sum15; ?>"/></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum16" type="text" id="sum16" size="5" 
      value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum15= 0;
while ($sum = mysql_fetch_assoc ($query_run)) {

    $sum15 += $sum['sum'];
}
echo $sum15; ?>"/></td>
    </tr>
  </table>
  <p>&nbsp;</p>
  <table width="200" border="0" align="left">
    <tr>
      <td align="center" valign="top"><p>...........................................................................</p>
      <p>(...........................................................................)</p>
      <p>ผู้จัดทำรายงาน</p></td>
    </tr>
  </table>
<table width="256" border="0" align="right">
    <tr>
      <td width="250" align="center"><p>.............................................................</p>
      <p>(นางนรมน โลไทยสงค์)</p>
      <p>ผู้อำนวยการสำนักงานบริหารทรัพย์สิน</p></td>
    </tr>
  </table>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p><div id="non-printable">
  <table width="200" border="0" align="center">
    <tr>
      <td align="center"> <p><a href="javascript:window.print()"><img src="image/printButton.png" width="30" height="30"></a><a href="http://localhost/bankrecycledb/admin/foradmin.php"><img src="image/home.gif" width="27" height="30" /></a></p>  </td>
    </tr>
  </table></div>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
  }
  return $theValue;
}
}
 
$colname_Recordset1 = "-1";
if (isset($_POST['word2'])) {
  $colname_Recordset1 = $_POST['word2'];
}
mysql_select_db($database_Myconnect, $Myconnect);
$query_Recordset1 = sprintf("SELECT * FROM bankrecycle WHERE date LIKE %s", GetSQLValueString("%" . $colname_Recordset1 . "%", "text"));
$Recordset1 = mysql_query($query_Recordset1, $Myconnect) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($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>Untitled Document</title>
<style type="text/css">
body,td,th {
font-family: Tahoma, Geneva, sans-serif;
font-size: 12px;
}
body {
background-image: url(image/3.jpg);
}
</style>
<style type="text/css"> 
 
#printable { display: block; }
 
@media print 
     #non-printable { display: none; } 
     #printable { display: block; } 
 
</style> 
</head>
 
<body>
<p><strong><center>ผลการค้นหาข้อมูล:</center></strong></p>
<table width="1200" height="98" border="1" align="center" bordercolor="#FFFF33">
  <tr>
    <td width="100" align="center" bgcolor="#00FF00"><strong>เลขที่บัญชี</strong></td>
    <td width="115" align="center" bgcolor="#00FF00"><strong>วัน/เดือน/ปี</strong></td>
    <td width="149" align="center" bgcolor="#00FF00"><strong>ชื่อ-นามสกุล</strong></td>
    <td colspan="4" align="center" valign="middle" bgcolor="#00FF00"><strong>พลาสติก</strong></td>
    <td colspan="6" align="center" bgcolor="#00FF00"><strong>โลหะ</strong></td>
    <td colspan="4" align="center" bgcolor="#00FF00"><strong>กระดาษ</strong></td>
    <td width="118" align="center" bgcolor="#00FF00"><strong>ขวดแก้ว/กก.</strong></td>
    <td width="109" align="center" bgcolor="#00FF00"><strong>รวม/กก.</strong></td>
  </tr>
  <?php do { ?>
    <tr>
      <td rowspan="2" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['id']; ?></td>
      <td rowspan="2" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['date']; ?></td>
      <td rowspan="2" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['name_last']; ?></td>
      <td width="146" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['list1']; ?></td>
      <td width="146" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['list2']; ?></td>
      <td width="146" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['list3']; ?></td>
      <td width="146" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['list4']; ?></td>
      <td width="146" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['l1']; ?></td>
      <td width="146" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['l2']; ?></td>
      <td width="146" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['l3']; ?></td>
      <td width="146" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['l4']; ?></td>
      <td width="146" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['l5']; ?></td>
      <td width="154" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['l6']; ?></td>
      <td width="154" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['s1']; ?></td>
      <td width="154" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['s2']; ?></td>
      <td width="154" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['s3']; ?></td>
      <td width="130" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['s4']; ?></td>
      <td rowspan="2" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['glass']; ?></td>
      <td rowspan="2" align="center" bgcolor="#FFFF99"><?php echo $row_Recordset1['sum']; ?></td>
    </tr>
    <tr>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num1']; ?></td>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num2']; ?></td>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num3']; ?></td>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num4']; ?></td>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num5']; ?></td>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num6']; ?></td>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num7']; ?></td>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num8']; ?></td>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num9']; ?></td>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num10']; ?></td>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num11']; ?></td>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num12']; ?></td>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num13']; ?></td>
      <td bgcolor="#FFFF99">กก.<?php echo $row_Recordset1['num14']; ?></td>
    </tr>
    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
 <table width="1200" height="66" border="1" align="center" bordercolor="#FFFF00">
    <tr>
      <td width="54" rowspan="2" align="center" bgcolor="#00FF00"><strong>รวม </strong></td>
      <td width="90" height="31" align="center" bgcolor="#00FF00"><strong>รวมกก./ใส</strong></td>
      <td width="87" align="center" bgcolor="#00FF00"><strong>รวมกก./ขาวขุ่น</strong></td>
      <td width="78" align="center" bgcolor="#00FF00"><strong>รวมกก./กรอบ</strong></td>
      <td width="82" align="center" bgcolor="#00FF00"><strong>รวมกก./รวม</strong></td>
      <td width="81" align="center" bgcolor="#00FF00"><strong>รวมกก./เหล็ก</strong></td>
      <td width="76" align="center" bgcolor="#00FF00"><strong>รวมกก./โลหะ</strong></td>
      <td width="99" align="center" bgcolor="#00FF00"><strong>รวมกก./อลูมิเนียม</strong></td>
      <td width="106" align="center" bgcolor="#00FF00"><strong>รวมกก./ทองเหลือง</strong></td>
      <td width="94" align="center" bgcolor="#00FF00"><strong>รวมกก./ทองแดง</strong></td>
      <td width="94" align="center" bgcolor="#00FF00"><strong>รวมกก./สังกะสี</strong></td>
      <td width="96" align="center" bgcolor="#00FF00"><strong>รวมกก.ขาวดำ</strong></td>
      <td width="136" align="center" bgcolor="#00FF00"><strong>รวมกก./ลัง</strong></td>
      <td width="158" align="center" bgcolor="#00FF00"><strong>รวมกก./รวม</strong></td>
      <td width="141" align="center" bgcolor="#00FF00"><strong>รวมกก./หนังสือพิมพ์</strong></td>
      <td width="120" align="center" bgcolor="#00FF00"><strong>รวมกก./ขวดแก้ว</strong></td>
      <td width="138" align="center" bgcolor="#00FF00"><strong>รวมยอดเงินทั้งหมด</strong></td>
    </tr>
    <tr>
      <td height="27" align="center" bgcolor="#FFFF66">
      <?php
$query = "SELECT * FROM bankrecycle ";
// ชุดคำสั่งสำหรับการค้นหา
if(isset($_POST['search_xxx'])){
$query.=" WHERE xxx='".$_POST['search_xxx']."' ";
}
$query_run = mysql_query($query);
$sum1= 0;
while ($row_Recordset1['num1']= mysql_fetch_assoc ($query_run)) {
    $sum1+= $row_Recordset1['num1']['num1'];
}
?><input name="sum1" type="text" id="sum1" size="5" 
   value="<?=$sum1?>"/></td>
 
<td align="center" bgcolor="#FFFF66"><input name="sum2" type="text" id="sum2" 
      size="5" value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum2= 0;
while ($num2 = mysql_fetch_assoc ($query_run)) {
 
    $sum2 += $num2['num2'];
}
echo $sum2; ?>"/></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum3" type="text" id="sum3" size="5"
      value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum3= 0;
while ($num3 = mysql_fetch_assoc ($query_run)) {
 
    $sum3 += $num3['num3'];
}
echo $sum3; ?>"/></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum4" type="text" id="sum4" size="5"
      value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum4= 0;
while ($num4 = mysql_fetch_assoc ($query_run)) {
 
    $sum4 += $num4['num4'];
}
echo $sum4; ?>" /></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum5" type="text" id="sum5" size="5" 
      value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum5= 0;
while ($num5 = mysql_fetch_assoc ($query_run)) {
 
    $sum5 += $num5['num5'];
}
echo $sum5; ?>"/></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum6" type="text" id="sum6" size="5"
      value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum6= 0;
while ($num6 = mysql_fetch_assoc ($query_run)) {
 
    $sum6 += $num6['num6'];
}
echo $sum6; ?>" /></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum7" type="text" id="sum7" size="5" 
      value="<?php $query = "SELECT * FROM bankrecycle ";
$query_run = mysql_query($query);
$sum7= 0;
while ($num7 = mysql_fetch_assoc ($query_run)) {
 
    $sum7 += $num7['num7'];
}
echo $sum7; ?>"/></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum8" type="text" id="sum8" size="5" 
      value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum8= 0;
while ($num8 = mysql_fetch_assoc ($query_run)) {
 
    $sum8 += $num8['num8'];
}
echo $sum8; ?>"/></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum9" type="text" id="sum9" size="5" 
      value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum9= 0;
while ($num9 = mysql_fetch_assoc ($query_run)) {
 
    $sum9 += $num9['num9'];
}
echo $sum9; ?>"/></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum10" type="text" id="sum10" size="5" 
      value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum10= 0;
while ($num10 = mysql_fetch_assoc ($query_run)) {
 
    $sum10 += $num10['num10'];
}
echo $sum10; ?>"/></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum11" type="text" id="sum11" size="5" 
      value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum11= 0;
while ($num11 = mysql_fetch_assoc ($query_run)) {
 
    $sum11 += $num11['num11'];
}
echo $sum11; ?>"/></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum12" type="text" id="sum12" size="5" 
      value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum12= 0;
while ($num12 = mysql_fetch_assoc ($query_run)) {
 
    $sum12 += $num12['num12'];
}
echo $sum12; ?>"/></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum13" type="text" id="sum13" size="5" 
      value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum13= 0;
while ($num13 = mysql_fetch_assoc ($query_run)) {
 
    $sum13 += $num13['num13'];
}
echo $sum13; ?>"/></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum14" type="text" id="sum14" size="5" 
      value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum14= 0;
while ($num14 = mysql_fetch_assoc ($query_run)) {
 
    $sum14 += $num14['num14'];
}
echo $sum14; ?>"/></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum15" type="text" id="sum15" size="5" 
      value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum15= 0;
while ($glass = mysql_fetch_assoc ($query_run)) {
 
    $sum15 += $glass['glass'];
}
echo $sum15; ?>"/></td>
      <td align="center" bgcolor="#FFFF66"><input name="sum16" type="text" id="sum16" size="5" 
      value="<?php $query = "SELECT * FROM bankrecycle";
$query_run = mysql_query($query);
$sum15= 0;
while ($sum = mysql_fetch_assoc ($query_run)) {
 
    $sum15 += $sum['sum'];
}
echo $sum15; ?>"/></td>
    </tr>
  </table>
  <p>&nbsp;</p>
  </table>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p><div id="non-printable">
  <table width="200" border="0" align="center">
    <tr>
      <td align="center"> <p><a href="javascript:window.print()"><img src="image/printButton.png" width="30" height="30"></a><a href="http://localhost/bankrecycledb/admin/foradmin.php"><img src="image/home.gif" width="27" height="30" /></a></p>  </td>
    </tr>
  </table></div>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>

คือว่าผมให้มันโชวในช่องครับ แต่มันก็รวมให้ทั้งหมดในฐานข้อมูลครับ
สมมติ ผมค้น หาจากวันที   มันก็จะออกมาแค่อันเดียวครับ  มันก็จะโชว์ผลรวมของผมทั้ง  แต่โชว์เพียงผลรวมที่ผมค้นหาครับ
 


โดย:  Soomsam77 IP: 202.28.38.xxx วันที่: 13-03-2015 เวลา: 13:57:56
 ความคิดเห็นที่ 1
เขียนโค้ดแปลก น่าจะทำเป็นตัวแปร แล้วเอาค่าไปใส่แทน

<?php
$query = "SELECT * FROM bankrecycle ";
// ชุดคำสั่งสำหรับการค้นหา
if(isset($_POST['search_xxx'])){
	$query.=" WHERE xxx='".$_POST['search_xxx']."' ";
}
$query_run = mysql_query($query);
$sum1= 0;
while ($row_Recordset1['num1']= mysql_fetch_assoc ($query_run)) {
    $sum1+= $row_Recordset1['num1']['num1'];
}
?>
<input name="sum1" type="text" id="sum1" size="5" value="<?=$sum1?>"/>



โค้ดเหมือนใช้โปรแกรม





โดย:  Ninenik IP: 171.96.90.xxx วันที่: 13-03-2015