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 > ช่วยแก้โค้ดหน่อยคะ ต้องพบอาจารย์พรุ่งนี้เเล้ว T^T มันติดerror เเละไม่โชว์ข้อมูลคะ



 

ช่วยแก้โค้ดหน่อยคะ ต้องพบอาจารย์พรุ่งนี้เเล้ว T^T มันติดerror เเละไม่โชว์ข้อมูลคะ

 



Topic : 073543



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



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




ขึ่น เเบบนี้คะ

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\salonss\emp1_report.php on line 99

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\salonss


Code (PHP)
<?
session_start();
include "connect.php";

$branch=$_GET[branch];
$emp=$_GET[emp];
?>  
<div id="sidebar">
	<td valign='top' style='padding-left:10px; padding-right:10px'>
	<div class="info" ><span class="welcome-message"><strong><p><u>รายงานรวมผู้ช่วยช่าง</u><br></p><br>
</div>
 <?    
        	  
 ?>                                                
<table  width="629" class="welcome-message">
   
        <!------เลือกช่าง------>
        
      <tr> <td width="224"><p> เลือกผู้ช่วยช่าง : <label>
    <select name="country" class="ntext" id="select" onChange="location.href='report.php?emp='+this.value+'&branch=<?=$branch?>&report=6&month=<?=$month?>';" style="width:200px" >
    <option value="0"  selected > --เลือกผู้ช่วยช่าง-- </option>   
			   <? //สร้างตัวแปรมาเพื่อไว้รับค่า
                $report=$_GET[report];		// แบบรายงาน
                $day=$_GET[day];			// วัน/เดือน
                $branch=$_GET[branch];		//สาขา
				//$change=$_GET[change];		//
                $date=$_GET[date];			//วันที่
                $month=$_GET[month];  		//เดือน
		
			$sql_line1 = "SELECT *  FROM employees where BranchID=$branch and PositionID=3 order by EmpName asc;";
                        
			$result_line1 = mysql_query($sql_line1) or die("error:  ".mysql_error());
			while($arr_line1  = mysql_fetch_array($result_line1)) {
						$an=$arr_line1[BookingTiME_Date];
						$n=  explode("-", $an);
						$year=$n[2]."-".$n[1]."-".$n[0];   
                ?>          
       <option value="<?=$arr_line1[EmpID]?>" <? if($arr_line1[EmpID]==$emp){echo "selected"; }?>  > <?=$arr_line1[EmpName]?> 	   </option>  
			<? } // end while ?>
	</select></label></p></td>
	</tr>
       
        <tr height="30"></tr>
        <!------เลือกช่าง1------>
    <? if($_GET[emp]){ ?>
         <?  $total=0;
        $total1=0;
        $total2=0;
        $total3=0;
        $total4=0;
        $total5=0;
        $total6=0;
        $total7=0;
        $totala=0;
        $totala1=0;
        $totala2=0;
        $totala3=0;
        $totala4=0;
        $totala5=0;
    $count=1;
      
        $dd = date('d-m-Y');
            $year=substr($dd,-4,4);
            $n=  explode("-",$date);
            $dayr=$n[2]."-".$n[1]."-".$n[0];
            
	for($i=1;$i<=12;$i++){
    if(($month==$i)&&($report==6)){ $ai="0".$i;
    
    $sql2="select t.Name,count(d.TypeID),sum(s.Price),sum(d.commision) from services s,servicetypes t ,servicedetail d where `BranchID`=$branch and `EmpID_Assis`=$emp and `RecieveTime_Date`
BETWEEN '$year-$ai-01' AND '$year-$ai-31' and s.ServiceID=d.ServiceID and d.TypeID=t.TypeID group by t.Name order by count(t.TypeID) desc";
    }
    if($_GET[date]!=""){
   $sql2="select t.Name,count(d.TypeID),sum(s.Price),sum(d.commision) from services s,servicetypes t ,servicedetail d where `BranchID`=$branch and `EmpID_Assis`=$emp and `RecieveTime_Date`='$dayr' and s.ServiceID=d.ServiceID and d.TypeID=t.TypeID group by t.Name order by count(t.TypeID) desc";   
    }
        }
    
    $result2=mysql_query($sql2); 
    
    ?>
        <tr class="welcome-message"><td><p>ชื่อช่าง : <? $sql3="select * from employees where EmpID=$emp";
                                                
                                                $result3=mysql_query($sql3);
                                                $row3=mysql_fetch_array($result3);
                                                echo $row3[EmpName];
                                                ?></p></td></tr>
    <tr><td colspan="6"><b>ตารางรวมผู้ช่วยช่างที่ 1</b></td></tr>
    <tr>
        <td>ชื่อบริการ</td>
        <td width="86">จำนวนบริการ</td>
        <td width="48">รวมเงิน</td>
        <td width="88">ค่าคอมมิชชั่น</td>
        <td width="59">ยอดสุทธิ</td>
        <td width="96">เรียงลำดับ</td>
            
    </tr>
   <?
    
    while($row2=  mysql_fetch_array($result2)){
        
        
    
        
     ?>
    <tr>
        <td><? $row2[0];?></td>
        <td><? $co=$row2[1]; echo $co;?></td>
        <td><? $price=$row2[2]; echo $price; ?></td>
        <td><? $com=$row2[3]; $com = round($com,2); echo $com ; ?></td>
        <td><? echo $net=$price-$com; ?></td>
        <td><?=$count?></td>
    </tr>
    
        <? 
            $total=$total+$price;
            $total1=$total1+$com;
            $total2=$total2+$cal;
            $total3=$total3+$co;
            $totala=$totala+$net;
          $count++; } ?>
     <tr height="30">
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
    <tr>
        <td>รวม</td>
        <td><?=$total3?></td>
        <td><?=$total?></td>
        <td><?=$total1?></td>
        <td><?=$totala?></td>
        <td></td>
    </tr>
    
	<? } ?>	
    <!-------------เลือกช่าง 2 --------------->
     <tr height="50">
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
    <? if($_GET[emp]){ ?>
         <?  
    $count=1;
      
        $dd = date('d-m-Y');
            $year=substr($dd,-4,4);
            $n=  explode("-",$date);
            $dayr=$n[2]."-".$n[1]."-".$n[0];
            
	for($i=1;$i<=12;$i++){
    if(($month==$i)&&($report==6)){ $ai="0".$i;
    
    $sql2="select t.Name,count(d.TypeID),sum(s.Price),sum(d.commision) from services s,servicetypes t ,servicedetail d where `BranchID`=$branch and `EmpID_Assis2`=$emp and `RecieveTime_Date`
BETWEEN '$year-$ai-01' AND '$year-$ai-31' and s.ServiceID=d.ServiceID and d.TypeID=t.TypeID group by t.Name order by count(t.TypeID) desc";
    }
    if($_GET[date]!=""){
   $sql2="select t.Name,count(d.TypeID),sum(s.Price),sum(d.commision) from services s,servicetypes t ,servicedetail d where `BranchID`=$branch and `EmpID_Assis2`=$emp and `RecieveTime_Date`='$dayr' and s.ServiceID=d.ServiceID and d.TypeID=t.TypeID group by t.Name order by count(t.TypeID) desc";   
    }
        }
    
    $result2=mysql_query($sql2); 
    
    ?>
    <tr><td colspan="6"><b>ตารางรวมผู้ช่วยช่างที่ 2</b></td></tr>
    <tr>
        <td>ชื่อบริการ</td>
        <td>จำนวนบริการ</td>
        <td>รวมเงิน</td>
        <td>ค่าคอมมิชชั่น</td>
        <td>ยอดสุทธิ</td>
        <td>เรียงลำดับ</td>
            
    </tr>
   <?
    
    while($row2=  mysql_fetch_array($result2)){
        
     ?>
    <tr>
        <td><?=$row2[0]?></td>
        <td><? $co=$row2[1]; echo $co;?></td>
        <td><? $price=$row2[2]; echo $price; ?></td>
        <td><? $com=$row2[3]; $com = round($com,2); echo $com ; ?></td>
        <td><? echo $net=$price-$com; ?></td>
        <td><?=$count?></td>
    </tr>
    
        <? 
            $totala1=$totala1+$price;
            $totala2=$totala2+$com;
            $totala3=$totala3+$cal;
            $totala4=$totala4+$co;
            $totala5=$totala5+$net;
          $count++; } ?>
     <tr height="30">
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
    <tr>
        <td>รวม</td>
        <td><?=$totala4?></td>
        <td><?=$totala1?></td>
        <td><?=$totala2?></td>
        <td><?=$totala5?></td>
        <td></td>
    </tr>
    
	
    <tr height="50">
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
    <tr>
        <td>รวมสุทธิ</td>
        <td><? echo $neta1=$total3+$totala4; ?></td>
        <td><? echo $neta2=$total+$totala1; ?></td>
        <td><? echo $neta3=$total1+$totala2; ?></td>
        <td><? echo $neta4=$totala+$totala5; ?></td>
        <td></td>   
    </tr>
    <? } ?>	
    <!------------แสดงทั้งหมดผู้ช่วยช่างที่ 1------------------>
      <? if($_GET[day]){ ?>
          <?    $count=1;
        $dd = date('d-m-Y');
            $year=substr($dd,-4,4);
            $n=  explode("-",$date);
            $dayr=$n[2]."-".$n[1]."-".$n[0];
            
	for($i=1;$i<=12;$i++){
    if(($month==$i)&&($report==6)){ $ai="0".$i;
           $sqlall=" select e.EmpName,count(d.TypeID),sum(s.Price),sum(d.commision) from services s,servicetypes t ,servicedetail d,employees e where s.`BranchID`=$branch and s.`EmpID_Assis`=e.EmpID and `RecieveTime_Date` BETWEEN '$year-$ai-01' AND '$year-$ai-31' and s.ServiceID=d.ServiceID and d.TypeID=t.TypeID group by s.EmpID_Assis order by count(t.TypeID) desc"; 
    }
    if($_GET[date]!=""){
        $sqlall=" select e.EmpName,count(d.TypeID),sum(s.Price),sum(d.commision) from services s,servicetypes t ,servicedetail d,employees e where s.`BranchID`=$branch and s.`EmpID_Assis`=e.EmpID and `RecieveTime_Date`='$dayr' and s.ServiceID=d.ServiceID and d.TypeID=t.TypeID group by s.EmpID_Assis order by count(t.TypeID) desc";
    }
    }
           
            $resultall=mysql_query($sqlall);
            $numq=  mysql_num_rows($resultall);
           
          ?> 
        <? if($numq!=0){?>
         <tr>
        <td>ชื่อบริการ</td>
        <td>จำนวนบริการ</td>
        <td>รวมเงิน</td>
        
        <td>ค่าคอมมิชชั่น</td>
        <td>ยอดสุทธิ</td>
        <td>เรียงลำดับ</td>
            
    </tr>
   <?
    
    while($rowall=mysql_fetch_array($resultall)){ 
    
     ?>
    <tr>
        <td><?=$rowall[0]?></td>
        <td><? $co=$rowall[1]; echo $co;?></td>
        <td><? $price=$rowall[2]; echo $price; ?></td>
        <td><? $com=$rowall[3]; $com = round($com,2); echo $com ; ?></td>
        <td><? echo $to=$price-$com; ?>
        <td><?=$count?></td>
    </tr>
    
        <? 
            $total=$total+$price;
            $total1=$total1+$com;
            $total2=$total2+$cal;
            $total3=$total3+$co;
          $count++; } ?>
     
    <tr>
        <td>รวม</td>
        <td><?=$total3?></td>
        <td><?=$total?></td>
        <td><?=$total1?></td>
        <td><? echo $neta=$total-$total1; ?></td>
        <td></td>
    </tr>
    <tr height="30">
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
        
        
       <?}else{ echo"<tr align='center'><td colspan='6'> No Data</td></tr>";} ?>
    <!------------------------------>
<!------------แสดงทั้งหมดผู้ช่วยช่างที่ 2------------------>
     
          <?    $count=1;
        $dd = date('d-m-Y');
            $year=substr($dd,-4,4);
            $n=  explode("-",$date);
            $dayr=$n[2]."-".$n[1]."-".$n[0];
            
	for($i=1;$i<=12;$i++){
    if(($month==$i)&&($report==6)){ $ai="0".$i;
           $sqlall=" select e.EmpName,count(d.TypeID),sum(s.Price),sum(d.commision) from services s,servicetypes t ,servicedetail d,employees e where s.`BranchID`=$branch and s.`EmpID_Assis2`=e.EmpID and `RecieveTime_Date` BETWEEN '$year-$ai-01' AND '$year-$ai-31' and s.ServiceID=d.ServiceID and d.TypeID=t.TypeID group by s.EmpID_Assis2 order by count(t.TypeID) desc"; 
    }
    if($_GET[date]!=""){
        $sqlall=" select e.EmpName,count(d.TypeID),sum(s.Price),sum(d.commision) from services s,servicetypes t ,servicedetail d,employees e where s.`BranchID`=$branch and s.`EmpID_Assis2`=e.EmpID and `RecieveTime_Date` = '$dayr' and s.ServiceID=d.ServiceID and d.TypeID=t.TypeID group by s.EmpID_Assis2 order by count(t.TypeID) desc";
    }
    }
            
            $resultall=mysql_query($sqlall);
            $numq=  mysql_num_rows($resultall);
           
          ?> 
        <? if($numq!=0){?>
         <tr>
        <td>ชื่อบริการ</td>
        <td>จำนวนบริการ</td>
        <td>รวมเงิน</td>
        
        <td>ค่าคอมมิชชั่น</td>
        <td>ยอดสุทธิ</td>
        <td>เรียงลำดับ</td>
            
    </tr>
   <?
    
    while($rowall=mysql_fetch_array($resultall)){ 
    
     ?>
    <tr>
        <td><?=$rowall[0]?></td>
        <td><? $co=$rowall[1]; echo $co;?></td>
        <td><? $price=$rowall[2]; echo $price; ?></td>
        <td><? $com=$rowall[3]; $com = round($com,2); echo $com ; ?></td>
        <td><? echo $to=$price-$com; ?>
        <td><?=$count?></td>
    </tr>
    
        <? 
            $total4=$total4+$price;
            $total5=$total5+$com;
            $total6=$total6+$cal;
            $total7=$total7+$co;
          $count++; } ?>
     
    <tr>
        <td>รวม</td>
        <td><?=$total7?></td>
        <td><?=$total4?></td>
        <td><?=$total5?></td>
        <td><? echo $netb=$total4-$total5; ?></td>
        <td></td>
    </tr>
    <tr height="30">
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
       <tr>
        <td>รวมสุทธิ</td>
        <td><? echo $net=$total3+$total7;?></td>
        <td><? echo $net1=$total+$total4;?></td>
        <td><? echo $net2=$total1+$total5;?></td>
        <td><? echo $net3=$neta+$netb;?></td>
        <td></td>
    </tr> 
        
       <?}else{ echo"<tr align='center'><td colspan='6'> No Data</td></tr>";}  ?>
    <!------------------------------>
    
    <? } ?>
</table>
 
</div>





Tag : PHP, MySQL, JavaScript, Ajax, jQuery







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2012-02-09 19:46:40 By : BNforever View : 941 Reply : 1
 

 

No. 1



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

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

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

ผมว่า sql น่าจะผิดคับ

ลองเอาไปยิงใน phpmyadmin เพื่อดูจุดผิดคับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-02-09 20:35:11 By : pjgunner.com
 

   

ค้นหาข้อมูล


   
 

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