Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > การค้นหาที่มากกว่า 2 เงื่อนไขครับ ไม่ทราบว่าทำยัง และต้องการรวมคะแนนด้วยครับ



 

การค้นหาที่มากกว่า 2 เงื่อนไขครับ ไม่ทราบว่าทำยัง และต้องการรวมคะแนนด้วยครับ

 



Topic : 119755



โพสกระทู้ ( 46 )
บทความ ( 1 )



สถานะออฟไลน์




ค้นหา
รูปตัวอย่างครับ

พอดีจากตัวเก่าที่เขียนได้คือค้นหาข้อมูลจากชื่อ แล้วจะรวมคะแนนให้เอง
แต่ปัญหาคือพอข้ามไปอีกเดือน คะแนนมันจะรวมกันหมดเลยยากแยก การค้นหาตามรูปครับ
และหลังจากการค้นหาแล้วให้รวมคะแนนไว้ด้วยดังเดิมครับ code ต่อไปนี้เพิ่มในส่วนเมนูที่จะทำการเลือกเข้ามาครับยังไม่ได้แก้ไขอะไร

Code (PHP)
<?php 
require_once('../css.css');
require_once('../Connections/connect.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_SA = "-1";
if (isset($_POST['textfield6'])) {
$colname_SA = $_POST['textfield6'];
}

mysql_select_db($database_connect, $connect);
$query_SA = sprintf("SELECT * FROM student WHERE stu_name LIKE %s",

 GetSQLValueString($colname_SA . "%", "text"));
$SA = mysql_query($query_SA, $connect) or die(mysql_error());
$row_SA = mysql_fetch_assoc($SA);
$totalRows_SA = mysql_num_rows($SA);
?>
<html>
<head>
<title></title>
</head>
<body>
<br />
<table width="99" border="0" align="right">
  <tr>
    <td width="45" align="center"><a href="../menu/Menu.php"><img src="../img/back.png" alt="" width="35" height="40" /></a></td>
    <td width="44" align="center"><a href="../login/logout.php"><img src="../img/login.png" alt="" width="35" height="40" /></a></td>
  </tr>
</table>
<br />
<br />
<br />
<br />
<table width="400" border="0" align="left">
  <tr>
    <td width="117" align="left"><table width="117" border="10">
      <tr>
        <td align="center">Data Search </td>
      </tr>
    </table></td>
    <td width="273" align="center"><table width="200" border="10" align="left">
      <tr>
        <td align="left"><?php echo "$colname_SA"  ?></td>
      </tr>
    </table></td>
  </tr>
</table>
<br>
<br>
<br>
<br>
<table border="3" bordercolor="#333333"  bgcolor="#FFFF99" width="auto" height="30" border="0" align="center"  class="simply">
<thead>
  <tr>
    <td align="center">วันที่</td>
    <td align="center">เวลา</td>
    <td align="center">ชื่อ - นามสกุล</td>
    <td align="center">ชั้น</td>
    <td align="center">ปีการศึกษา</td>
    <td align="center">ภาคเรียน</td>
    <td align="center">พฤติกรรม</td>
    <td align="center">คะแนน +</td>
    <td align="center">คะแนน -</td>
    <td align="center">บันทึกโดย</td>
  </tr>
</thead>
  <?php do { ?>
    <tr>
      <td align="center"><?php echo $row_SA['stu_date']; ?></td>
      <td align="center"><?php echo $row_SA['stu_time']; ?></td>
      <td align="center"><?php echo $row_SA['stu_name']; ?></td>
      <td align="center"><?php echo $row_SA['stu_matyaum']; ?></td>
      <td align="center"><?php echo $row_SA['stu_pakrian']; ?></td>
      <td align="center"><?php echo $row_SA['stu_term']; ?></td>
      <td><?php echo $row_SA['stu_preutgtigam']; ?></td>
      <td align="center"><?php echo $row_SA['stu_scoer_d']; ?></td>
      <td align="center"><?php echo $row_SA['stu_scoer_l']; ?></td>
      <td align="center"><?php echo $row_SA['stu_teacher_save']; ?></td>
      <td align="center"><a href="search_print.php?SA=<?php echo $row_SA['stu_id'];?>">PRINT</a></td>
    </tr>
    <?php } while ($row_SA = mysql_fetch_assoc($SA)); ?>
</table>
<p>
<?php
mysql_free_result($SA);
?>
<form action="" method="get">
  <br>
     <table width="441" height="66" border="0" align="right">
    <tr>
    <td colspan="3" align="left" valign="middle">
<?php
$sql = "SELECT stu_name,stu_preutgtigam,COUNT(*) AS icount FROM student WHERE stu_name='$colname_SA'  GROUP BY stu_preutgtigam,stu_name";
$q = mysql_query($sql);
while ($row = mysql_fetch_array($q, MYSQL_NUM)) {
printf ("%s  %s จำนวน %s ครั้ง", $row[0], $row[1], $row[2]);
echo "<hr/>";
}
?>
</td>
    </tr>
</table>
     <br>
     <br>
     <br>
     <br>
  <br>
  <br>
</form><form action="" method="get">
    <br>
    <table align="center">
    <tr>
<td align="left" valign="top">
<?php 
$sum ="select sum(stu_scoer_l) as sum_paid from student where stu_name='$colname_SA' ";
$query_sum=mysql_query($sum);
$result1 = mysql_fetch_array($query_sum);
?>
      <label for="textfield"></label>
      <input name="textfield" type="text" id="1" value="<?php echo "คะแนนพฤติกรรมเชิงลบ = ".$result1["sum_paid"]; ?>" readonly />
</td>


<td align="left" valign="top">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <?php 
$sum ="select sum(stu_scoer_d) as sum_paid from student where stu_name='$colname_SA' ";
$query_sum=mysql_query($sum);
$result2 = mysql_fetch_array($query_sum);
?>
      <label for="textfield3"></label>
      <input name="textfield2" type="text" id="2" value="<?php echo "คะแนนพฤติกรรมเชิงบวก = ".$result2["sum_paid"]; ?>" readonly />
</td>
    
<td align="left" valign="top">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <?php 
$sum ="select sum(stu_scoer_d - stu_scoer_l) as sum_paid from student where stu_name='$colname_SA' ";
$query_sum=mysql_query($sum);
$result3 = mysql_fetch_array($query_sum);
$a=$result1["sum_paid"]; //Pd
$b=$result2["sum_paid"]; //Pl
$c=$result3["sum_paid"]; //a-b
$d=100; //100
$e=($d+$c);
?>
        <label for="textfield3"></label>
        <input name="textfield2" type="text" id="2" value="<?php echo "คะแนนพฤติกรรมคงเหลือ = ".$e ?>" readonly />
</td>
    </tr>
  
</table>
    <p>&nbsp;</p>
</form>
</body>
</html>




Tag : PHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2015-11-05 16:20:49 By : apisit542 View : 1412 Reply : 12
 

 

No. 1



โพสกระทู้ ( 1,150 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

T_T

เงื่อนไขจากอะไรละคับ ปีการศึกษา จากโน่น จากนี่จากนั้น ตอน ไป select ข้อมูลก็ ใส่มันลงไปด้วย เท่านั้นเอง

$query_SA = sprintf("SELECT * FROM student WHERE stu_name LIKE %s and ปีการศึกษา = xx and โน่นนี่นั่น = xx")






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-11-05 16:23:57 By : progamer2000
 


 

No. 2



โพสกระทู้ ( 46 )
บทความ ( 1 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 1 เขียนโดย : progamer2000 เมื่อวันที่ 2015-11-05 16:23:57
รายละเอียดของการตอบ ::
ประมานนี้หรือเปล่า ?
https://www.thaicreate.com/php/forum/119529.html


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-11-05 16:57:39 By : apisit542
 

 

No. 3



โพสกระทู้ ( 1,150 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

คล้ายๆกันแหละครับ ลองนำมาประยุกต์ใช้
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-11-05 17:05:51 By : progamer2000
 


 

No. 4



โพสกระทู้ ( 46 )
บทความ ( 1 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 3 เขียนโดย : progamer2000 เมื่อวันที่ 2015-11-05 17:05:51
รายละเอียดของการตอบ ::
ครับ เดี่ยวผมลองดูก่อนแล้วจะมาถามต่อแล้วถามได้จากไหนถ้าสงสัยอีก

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-11-05 17:10:13 By : apisit542
 


 

No. 5



โพสกระทู้ ( 1,636 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

จริงแล้วก็แก้ตาม คห 1 น่ะครับ ใส่ condition เพิ่มใน where clause อะครับ
จะเอาเดือนไหน ก็
Code (PHP)
$query_SA = sprintf(
     "SELECT * FROM student WHERE stu_name LIKE %s and month(fielddate)=%s ",
     GetSQLValueString($colname_SA . "%", "text"), $varMonth
);


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-11-06 13:12:25 By : NewbiePHP
 


 

No. 6



โพสกระทู้ ( 46 )
บทความ ( 1 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 5 เขียนโดย : NewbiePHP เมื่อวันที่ 2015-11-06 13:12:25
รายละเอียดของการตอบ ::
ประเด็นคือตรงเดือนผมเก็บเป็น
2015-11-01 ประมาณนี้ครับ แต่เวลาหาจะให้หาเฉพาะเดือนยังไงตรงนี้แหละครับ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-11-06 14:22:26 By : apisit542
 


 

No. 7



โพสกระทู้ ( 1,636 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

ก็เก็บถูกแล้วครับ ลองง่าย select fielddate, month( fielddate) as m from tablename limit 1

ลองแค่นี้ บน phpmyadmin ดูก่อน
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-11-06 14:53:39 By : NewbiePHP
 


 

No. 8



โพสกระทู้ ( 46 )
บทความ ( 1 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 7 เขียนโดย : NewbiePHP เมื่อวันที่ 2015-11-06 14:53:39
รายละเอียดของการตอบ ::
ค้นหา
การเก็บใน db ตาม คห.1 เขียนแล้วไม่ขึ้น

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-11-06 15:22:22 By : apisit542
 


 

No. 9



โพสกระทู้ ( 46 )
บทความ ( 1 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 7 เขียนโดย : NewbiePHP เมื่อวันที่ 2015-11-06 14:53:39
รายละเอียดของการตอบ ::
มันประมานนี้ไหม

ด้านบน
$select = $_POST['select'];
$select1 = $_POST['select1'];
$select2 = $_POST['select2'];
$select3 = $_POST['select3'];
$select4 = $_POST['select4'];
$name = $_POST['textfield6'];




ส่วนล่าง(ใช้ในการทดสอบ SQL เท่านั้น)
ปล. ตรงเดือนที่เดิม :(

SELECT (stu_date,stu_name,stu_matyaum,stu_pakrian,stu_term,stu_preutgtigam )
FROM student
WHERE `stu_matyaum`="$1" AND `stu_pakrian`="$2" AND`stu_term`="$3" AND`stu_preutgtigam`="$4" AND `stu_date`="$5" AND `stu_name`="$6"


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-11-06 17:08:34 By : apisit542
 


 

No. 10



โพสกระทู้ ( 1,636 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

ทดสอบตัวอย่างง่ายๆก่อนนะครับ จะได้เข้าใจ เปลี่ยน ชื่อฟีลด์ ชื่อตารางให้ตรงกับที่มี
Code (PHP)
<?php
$curtime=time(); // อ่านค่าเวลามาเก็บไว้ในตัวแปร
$curmonth  = date('Y-m', $curtime);// 2015-11 อ่านเฉพาะ ปีเดือนเตรียมใช้ตรวจสอบ
$db=new mysqli( 'localhost', 'username', 'password', 'databasename'); 
// เชื่อมต่อด้วย mysql i  oop
$result=$db->query( "select * from table where left(dte,7)='$curmonth' limit 10");
// คิวรี่ ข้อมุลเอาเฉพาะข้อมูลของเดือนนี้ จำนวน 10 เรคคอร์ด
echo "<table border=2 cellpadding=2 cellspacint=2 >"; // แสดงในรูปแบบตาราง
while( $ro=$result->fetch_assoc()) echo '<tr><td>', implode('</td><td>',$ro), '</td></tr>';
echo "<table>";




ประวัติการแก้ไข
2015-11-06 18:10:43
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-11-06 18:09:20 By : NewbiePHP
 


 

No. 11



โพสกระทู้ ( 46 )
บทความ ( 1 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 10 เขียนโดย : NewbiePHP เมื่อวันที่ 2015-11-06 18:09:20
รายละเอียดของการตอบ ::
ผมแก้ไขได้แล้วนะครับ แต่เป็นการค้นหาโดยต้องกรอกข้อมูลทุกช่องเลยถึงจะค้นหา
ส่วนวันที่นั้นผมไปแก้ตรง เมนูเลือกให้ส่งค่าที่ต้องการไป แล้วไปเขียนตรงค้นหาให้หาค่าวันที่ '%____-__%' ในลักษณะนี้แทน ผมว่ามันมีข้อเสียนั้นแหละ มีอะไรแนะนำเพิ่มเติมบ้างไหมครับได้นำไปปรับเปลี่ยน

Code (PHP)
<?php 
require_once('../../Connections/connect.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;
}
}

$txt1_Recordset1 = "-1";
if (isset($_POST['textfield6'])) {
  $txt1_Recordset1 = $_POST['textfield6'];
}
$txt2_Recordset1 = "-1";
if (isset($_POST['select'])) {
  $txt2_Recordset1 = $_POST['select'];
}
$txt4_Recordset1 = "-1";
if (isset($_POST['select2'])) {
  $txt4_Recordset1 = $_POST['select2'];
}
$txt5_Recordset1 = "-1";
if (isset($_POST['select3'])) {
  $txt5_Recordset1 = $_POST['select3'];
}
$txt6_Recordset1 = "-1";
if (isset($_POST['select1'])) {
  $txt6_Recordset1 = $_POST['select1'];
}
mysql_select_db($database_connect, $connect);
$query_Recordset1 = sprintf("SELECT * FROM student WHERE stu_name LIKE %s AND stu_matyaum LIKE %s AND stu_pakrian LIKE %s AND stu_term  LIKE %s AND stu_date LIKE %s ", GetSQLValueString($txt1_Recordset1, "text"),GetSQLValueString($txt2_Recordset1, "text"),GetSQLValueString($txt4_Recordset1, "text"),GetSQLValueString($txt5_Recordset1, "text"),GetSQLValueString("%" . $txt6_Recordset1 . "%", "text"));
$Recordset1 = mysql_query($query_Recordset1, $connect) 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" />
</head>
<body>
<br />
<table width="99" border="0" align="right">
  <tr>
    <td width="45" align="center"><a href="../../menu/Menu.php"><img src="../../img/back.png" alt="" width="35" height="40" /></a></td>
    <td width="44" align="center"><a href="../../login/logout.php"><img src="../../img/login.png" alt="" width="35" height="40" /></a></td>
  </tr>
</table>
<br />
<br />
<br />
<br />
<br />
<table width="50" border="0" align="center">
  <tr>
    <td><img src="../../img/1909234_246763478835965_356104541_o.png" width="289" height="331" /></td>
  </tr>
</table>
<br />
<hr align="center" size="5" />
<br />
<form id="form1" name="form1" method="post" action="<?php echo $_SERVER['SCRIPT_NAME'];?>">
  <table width="681" border="0" align="center">
    <tr>
      <td width="169" align="left" valign="top">
        <table width="165" border="0" align="center">
          <tr>
            <td align="left" valign="middle"><p>
              <select name="select" id="select">
                  <option>- เลือกข้อมูลห้องเรียน -</option>
                  <option value="1 ห้อง 1">ชั้นมัธยมศึกษาปีที่ 1/1</option>
                  <option value="1 ห้อง 2">ชั้นมัธยมศึกษาปีที่ 1/2</option>
                  <option value="2 ห้อง 1">ชั้นมัธยมศึกษาปีที่ 2/1</option>
                  <option value="2 ห้อง 2">ชั้นมัธยมศึกษาปีที่ 2/2</option>
                  <option value="3 ห้อง 1">ชั้นมัธยมศึกษาปีที่ 3/1</option>
                  <option value="3 ห้อง 2">ชั้นมัธยมศึกษาปีที่ 3/2</option>
                  <option value="4 ห้อง 1">ชั้นมัธยมศึกษาปีที่ 4/1</option>
                  <option value="4 ห้อง 2">ชั้นมัธยมศึกษาปีที่ 4/2</option>
                  <option value="5 ห้อง 1">ชั้นมัธยมศึกษาปีที่ 5/1</option>
                  <option value="5 ห้อง 2">ชั้นมัธยมศึกษาปีที่ 5/2</option>
                  <option value="6 ห้อง 1">ชั้นมัธยมศึกษาปีที่ 6/1</option>
                  <option value="6 ห้อง 2">ชั้นมัธยมศึกษาปีที่ 6/2</option>
                </select>
              </p></td>
          </tr>
        </table>
        <p>
      <td width="151" align="left" valign="top"><table width="145" border="0" align="center">
        <tr>
          <td align="left"><select name="select1" id="select1">
              <option>- เลือกข้อมูลเดือน -</option>
              <option value="2015-01">มกราคม</option>
              <option value="2015-02">กุมภาพันธ์</option>
              <option value="2015-03">มีนาคม</option>
              <option value="2015-04">เมษายน</option>
              <option value="2015-05">พฤศภาคม</option>
              <option value="2015-06">มิถุนายน</option>
              <option value="2015-07">กรกฎาคม</option>
              <option value="2015-08">สิงหาคม</option>
              <option value="2015-09">กันยายน</option>
              <option value="2015-10">ตุลาคม</option>
              <option value="2015-11">พฤศจิกายน</option>
              <option value="2015-12">ธันวาคม</option>
            </select></td>
        </tr>
      </table>      
      <td width="181" align="left" valign="top"><table width="177" border="0" align="center">
        <tr>
          <td align="left"><select name="select2" id="select2">
            <option>- เลือกข้อมูลปีการศึกษา -</option>
              <option value="2558">2558</option>
              <option value="2559">2559</option>
              <option value="2560">2560</option>
              <option value="2561">2561</option>
              <option value="2562">2562</option>
              <option value="2563">2563</option>
              <option value="2564">2564</option>
              <option value="2565">2565</option>
          </select></td>
        </tr>
      </table>      
      <td width="162" align="left" valign="top"><table width="165" border="0" align="center">
        <tr>
          <td align="left"><select name="select3" id="select3">
            <option>- เลือกข้อมูลภาคเรียน -</option>
              <option value="1">1</option>
              <option value="2">2</option>
          </select></td>
        </tr>
      </table>      </tr>
  </table>
  <br />
  <table width="800" border="0" align="center">
    <tr>
      <td align="center"><input name="textfield6" type="text" id="textfield6" placeholder='กรุณากรอกชื่อ - นามสกุลนักเรียน' size="20"/>
      <input type="submit" name="button6" id="button6" value="ค้นหา" /></td>
    </tr>
  </table>
</form>
<p>
<table border="3" bordercolor="#333333"  bgcolor="#FFFF99" width="auto" height="30" border="0" align="center"  class="simply">
<thead>
  <tr>
    <td align="center">วันที่</td>
    <td align="center">เวลา</td>
    <td align="center">ชื่อ - นามสกุล</td>
    <td align="center">ชั้น</td>
    <td align="center">ปีการศึกษา</td>
    <td align="center">ภาคเรียน</td>
    <td align="center">พฤติกรรม</td>
    <td align="center">คะแนน +</td>
    <td align="center">คะแนน -</td>
    <td align="center">บันทึกโดย</td>
  </tr>
</thead>
  <?php do { ?>
    <tr>
      <td align="center"><?php echo $row_Recordset1['stu_date']; ?></td>
      <td align="center"><?php echo $row_Recordset1['stu_time']; ?></td>
      <td align="center"><?php echo $row_Recordset1['stu_name']; ?></td>
      <td align="center"><?php echo $row_Recordset1['stu_matyaum']; ?></td>
      <td align="center"><?php echo $row_Recordset1['stu_pakrian']; ?></td>
      <td align="center"><?php echo $row_Recordset1['stu_term']; ?></td>
      <td><?php echo $row_Recordset1['stu_preutgtigam']; ?></td>
      <td align="center"><?php echo $row_Recordset1['stu_scoer_d']; ?></td>
      <td align="center"><?php echo $row_Recordset1['stu_scoer_l']; ?></td>
      <td align="center"><?php echo $row_Recordset1['stu_teacher_save']; ?></td>
      <td align="center"><a href="../search_print.php?SA=<?php echo $row_Recordset1['stu_id'];?>">PRINT</a></td>
    </tr>
    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
<p>
<?php
mysql_free_result($Recordset1);
?>


<form action="" method="get">
  <br>
     <table width="441" height="66" border="0" align="right">
    <tr>
    <td colspan="3" align="left" valign="middle">
<?php
$sql = "SELECT stu_name,stu_preutgtigam,COUNT(*) AS icount FROM student WHERE stu_name='$txt1_Recordset1' AND stu_matyaum='$txt2_Recordset1' AND stu_pakrian='$txt4_Recordset1' AND stu_term='$txt5_Recordset1' AND stu_date LIKE '%$txt6_Recordset1%' GROUP BY stu_preutgtigam,stu_name";
$q = mysql_query($sql);
while ($row = mysql_fetch_array($q, MYSQL_NUM)) {
printf ("%s  %s จำนวน %s ครั้ง", $row[0], $row[1], $row[2]);
echo "<hr>";
}
?>
</td>
    </tr>
</table>
</form>


<form action="" method="get">
<br>
<br>
<br>
<table align="center">
<tr>
<td align="left" valign="top">
<?php 
$sum ="select sum(stu_scoer_l) as sum_paid from student where stu_name='$txt1_Recordset1' AND stu_matyaum='$txt2_Recordset1' AND stu_pakrian='$txt4_Recordset1' AND stu_term='$txt5_Recordset1' AND stu_date LIKE '%$txt6_Recordset1%'";
$query_sum=mysql_query($sum);
$result1 = mysql_fetch_array($query_sum);
?>
      <label for="textfield"></label>
      <input name="textfield" type="text" id="1" value="<?php echo "คะแนนพฤติกรรมเชิงลบ = ".$result1["sum_paid"]; ?>" readonly />
</td>


<td align="left" valign="top">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <?php 
$sum ="select sum(stu_scoer_d) as sum_paid from student where stu_name='$txt1_Recordset1' AND stu_matyaum='$txt2_Recordset1' AND stu_pakrian='$txt4_Recordset1' AND stu_term='$txt5_Recordset1' AND stu_date LIKE '%$txt6_Recordset1%'";
$query_sum=mysql_query($sum);
$result2 = mysql_fetch_array($query_sum);
?>
      <label for="textfield3"></label>
      <input name="textfield2" type="text" id="2" value="<?php echo "คะแนนพฤติกรรมเชิงบวก = ".$result2["sum_paid"]; ?>" readonly />
</td>
    
<td align="left" valign="top">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <?php 
$sum ="select sum(stu_scoer_d - stu_scoer_l) as sum_paid from student where stu_name='$txt1_Recordset1' AND stu_matyaum='$txt2_Recordset1' AND stu_pakrian='$txt4_Recordset1' AND stu_term='$txt5_Recordset1' AND stu_date LIKE '%$txt6_Recordset1%'";
$query_sum=mysql_query($sum);
$result3 = mysql_fetch_array($query_sum);
$a=$result1["sum_paid"]; //Pd
$b=$result2["sum_paid"]; //Pl
$c=$result3["sum_paid"]; //a-b
$d=100; //100
$e=($d+$c);
?>
<label for="textfield3"></label>
<input name="textfield2" type="text" id="2" value="<?php echo "คะแนนพฤติกรรมคงเหลือ = ".$e ?>" readonly />
</td>
    </tr>
  
</table>
    <p>&nbsp;</p>
</form>

</body>
</html>



แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-11-07 13:55:21 By : apisit542
 


 

No. 12



โพสกระทู้ ( 22 )
บทความ ( 0 )



สถานะออฟไลน์


ผมใช้แบบนี้นะ หาจากในเว็บนี้ละ ฮาๆ
Code (PHP)
  <strong>   ค้นหา  <form class="navbar-form" role="search" method="POST" action="?page=search_it">
						<input type="text" class="form-control" placeholder="ไอดี" name="id" id="id" autocomplete="off" />
						<select name="saka" id="saka" class="form-control">
                            <option value="0">เลือกสาขา</option>
                            <?php
                            while ($objQuery = mysql_fetch_array($Query)) {
                                ?>
                                <option value="<?php echo $objQuery['name']; ?>">
                                    <?php echo $objQuery['name']; ?>
                                </option>
								
                                <?php
                            }
                            ?>
                        </select>
								<select class="form-control" name ="status" id="status">
											<option value="0">เลือกสถานะ</option>
											<option value="Panding"><span class='label label-info'><b>รอการแก้ไข</b></span></option>
											<option value="Relate"><span class='label label-warning'><b>กำลังแก้ไข</b></span></option>
											<option value="Approve"><span class='label label-success'><b>เรียบร้อย</b></span></option>
											<option value="Going"><span class='label label-success'><b>กำลังส่งของ</b></span></option>
								</select>
        <button type="submit" class="btn btn-default">ตกลง</button>
      </form>
	  </strong>  


Code (PHP)
<?php
include("../connection/db_login.php");
$id = $_POST["id"];
$saka = $_POST["saka"];
$status = $_POST["status"];
$where = '';  

if($id){
$where  .= " and id like '%$id%' ";

}

if($saka){

$where .= " and saka like '$saka' ";

}

if($status){

$where .= " and status like '$status' ";

}
	$strSQL = "select * from it_repair where 1 $where";
	$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-11-11 09:45:32 By : nutemoza
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : การค้นหาที่มากกว่า 2 เงื่อนไขครับ ไม่ทราบว่าทำยัง และต้องการรวมคะแนนด้วยครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 00
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่