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 > สอบถามเกี่ยวกับการนับจำนวนประเภท ที่แสดงจากฐานข้อมูล



 

สอบถามเกี่ยวกับการนับจำนวนประเภท ที่แสดงจากฐานข้อมูล

 



Topic : 123988



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

สมาชิกที่ใส่เสื้อไทยครีเอท

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




ผมค้นหาข้อมูลจากวันที่ แล้วแสดงเป็นตาราง
และต้องการให้นับจำนวนประเภท
รบกวนด้วยครับ

count

Code (PHP)
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
</head>
<style type="text/css">
body {
	background-image: url(file:///D|/AppServ/www/Old-Paper-Background-520x346.jpg);
}
</style>
</head>
<body>

     <title></title>
     <link type="text/css" href="flora.calendars.picker.css" rel="stylesheet"/>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.calendars.min.js"></script>
<script type="text/javascript" src="jquery.calendars.plus.min.js"></script>
<script type="text/javascript" src="jquery.calendars.picker.min.js"></script>
<script type="text/javascript" src="jquery.calendars.thai.min.js"></script>
<script type="text/javascript" src="jquery.calendars.thai-th.js"></script>
<script type="text/javascript" src="jquery.calendars.picker-th.js"></script>

<script type="text/javascript">
$(function() {
    $('#mydate').calendarsPicker({calendar: $.calendars.instance('thai','th')});
	////$("#mydate").datepicker({ dateFormat: 'yy-mm-dd',minDate:0 ,maxDate: 7});
	
});
</script>

<script type="text/javascript">
$(function() {
    $('#mydate1').calendarsPicker({calendar: $.calendars.instance('thai','th')});
});
</script>


<script type="text/javascript">
$(function() {
    $('#mydate2').calendarsPicker({calendar: $.calendars.instance('thai','th')});
});
</script>

<script type="text/javascript">
$(function() {
    $('#mydate3').calendarsPicker({calendar: $.calendars.instance('thai','th')});
});
</script>




<form name="frmSearch" method="get" action="<?=$_SERVER['file:///D|/AppServ/www/SCRIPT_NAME'];?>">
  <table width="865" border="1" align="center">
  <tr>    </tr>
  </table>
  <table width="599" border="1" align=center>
  <tr>
<th>กรอกตำแหน่ง
<input name="txtKeyword" type="text"  id="mydate1"    onkeyup="beginchk(this,event)"   value="<?=$_GET["txtKeyword"];?>">
<input name="txtKeyword2" type="text"  id="mydate2"    onkeyup="beginchk(this,event)"   value="<?=$_GET["txtKeyword2"];?>">
<input type="submit" value="Search"></th>
</tr>
</table>
</form>
<?

$from=$_GET["txtKeyword"];
$strYear = substr($from,6,4)-543;
$strMonth = substr($from,3,2);
$strDay = substr($from,0,2);       
$birth = $strYear."-".$strMonth."-".$strDay;

$from2=$_GET["txtKeyword2"];
$strYear2 = substr($from2,6,4)-543;
$strMonth2 = substr($from2,3,2);
$strDay2 = substr($from2,0,2);       
$birth2 = $strYear2."-".$strMonth2."-".$strDay2;

if($_GET["txtKeyword"] != "")
{
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("dataidp3");

mysql_query("SET NAMES UTF8");


///$strSQL = "SELECT * FROM  idp3  WHERE (day LIKE '%".$_GET["txtKeyword"]."%' or  day LIKE '%".$_GET["txtKeyword"]."%' )";
$strSQL = "SELECT   idp3.ID , idp3.name,idp3.day ,team.teamname,idp3.teamid
,count(idp3.teamid = 1) as aaa ,count(idp3.teamid = 2) as bbb ,count(idp3.teamid = 3) as ccc
 FROM  idp3 

left join team on idp3.teamid = team.teamid WHERE  idp3.day BETWEEN  '$birth'   and   '$birth2' 

group by idp3.ID 

";

$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");


$day=$objResult["day"];


mysql_query("SET NAMES UTF8");



?>
  <?


?>

        
<center><table width="627" border="1">
  <tr>
    <td width="617"><table width="621" border="1" align=center>
      <tr>
        <th width="124" bgcolor="#EEEEEE">ลำดับ</th>
        <th width="286" bgcolor="#EEEEEE"> <div align="center">เรื่อง</div></th>

        <th width="189" bgcolor="#EEEEEE"> <div align="center">ประเภท</div></th>
        
      </tr>


      <?
while($objResult = mysql_fetch_array($objQuery))

{
?>
      <tr>
        <td height="22" bgcolor="#EEEEEE"><?=$objResult["ID"];?></td>
  
      <td bgcolor="#EEEEEE"><?=$objResult["name"];?></td>
    <td bgcolor="#EEEEEE">  <?=$objResult["teamname"];?></td>
     
      <?
}
?>
    </table></td>
  </tr>
  <?
 
  ?>
</table>
<p>
  <?
mysql_close($objConnect);
}

?>
</p>
<p>ประเภท 1 จำนวน
  
  <label for="textfield"></label>
<input type="text" name="textfield2" id="textfield2">
</p>
<p>ประเภท 2 จำนวน
  <input type="text" name="textfield" id="textfield">
</p>
<p>ประเภท 3 จำนวน
  <input type="text" name="textfield3" id="textfield3">
</p>
<p>&nbsp;</p>
</body>
</html>




Tag : PHP, MySQL







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2016-07-25 11:42:13 By : puldool View : 997 Reply : 4
 

 

No. 1



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



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


ลองแบบนี้ดูนะครับ

Code (PHP)
$strSQL = "SELECT   
idp3.ID ,
idp3.name,
idp3.day ,
team.teamname,idp3.teamid,
count(idp3.teamid) as team
FROM  idp3 
left join team on idp3.teamid = team.teamid 

WHERE  idp3.day BETWEEN  '$birth'   and   '$birth2'

group by idp3.ID,idp3.teamid";







แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-07-25 13:15:06 By : thesin18598
 


 

No. 2



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

สมาชิกที่ใส่เสื้อไทยครีเอท

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


ถ้าต้องการแบ่งประเภท และจำนวนนับ ลงตาม textxbox จะต้องทำประมาณไหนครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-07-25 13:32:34 By : puldool
 

 

No. 3



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



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


แบบนี้ก็น่าจะได้นะ
Code (PHP)
$strSQL = "SELECT   
idp3.ID ,
idp3.name,
idp3.day ,
team.teamname,idp3.teamid,
team.team_name,****
count(idp3.teamid) as team
FROM  idp3 
left join team on idp3.teamid = team.teamid 

WHERE  idp3.day BETWEEN  '$birth'   and   '$birth2'

group by idp3.ID,idp3.teamid";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");

while($objResult = mysql_fetch_array($objQuery)){
echo "ประเภท".$objResult["team_name"]."จำนวน".$objResult["team"];
}

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-07-25 14:38:01 By : thesin18598
 


 

No. 4



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

สมาชิกที่ใส่เสื้อไทยครีเอท

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


ขอโทษนะครับถ้าไม่ตรงจุด

หรือผมเข้าใจผิดต้องขออภัยครับ

ูเช่นข้อมูลมี ประเภทที่ 3 จำนวน 2 เรื่อง


ผลที่ได้ต้องการประปาณนี้ครับ

ประเภทที่ 1 - เรื่อง

ประเภทที่ 2 - เรื่อง

ประเภทที่ 3 2 เรื่อง
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-07-26 15:56:13 By : puldool
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : สอบถามเกี่ยวกับการนับจำนวนประเภท ที่แสดงจากฐานข้อมูล
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 03
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 อัตราราคา คลิกที่นี่