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,038

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


[PHP] ช่วยแก้โค้ดหน่อยคะ ต้องพบอาจารย์พรุ่งนี้เเล้ว 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)
001.<?
002.session_start();
003.include "connect.php";
004. 
005.$branch=$_GET[branch];
006.$emp=$_GET[emp];
007.?> 
008.<div id="sidebar">
009.    <td valign='top' style='padding-left:10px; padding-right:10px'>
010.    <div class="info" ><span class="welcome-message"><strong><p><u>รายงานรวมผู้ช่วยช่าง</u><br></p><br>
011.</div>
012. <?   
013.               
014. ?>                                               
015.<table  width="629" class="welcome-message">
016.    
017.        <!------เลือกช่าง------>
018.         
019.      <tr> <td width="224"><p> เลือกผู้ช่วยช่าง : <label>
020.    <select name="country" class="ntext" id="select" onChange="location.href='report.php?emp='+this.value+'&branch=<?=$branch?>&report=6&month=<?=$month?>';" style="width:200px" >
021.    <option value="0"  selected > --เลือกผู้ช่วยช่าง-- </option>  
022.               <? //สร้างตัวแปรมาเพื่อไว้รับค่า
023.                $report=$_GET[report];      // แบบรายงาน
024.                $day=$_GET[day];            // วัน/เดือน
025.                $branch=$_GET[branch];      //สาขา
026.                //$change=$_GET[change];        //
027.                $date=$_GET[date];          //วันที่
028.                $month=$_GET[month];        //เดือน
029.         
030.            $sql_line1 = "SELECT *  FROM employees where BranchID=$branch and PositionID=3 order by EmpName asc;";
031.                         
032.            $result_line1 = mysql_query($sql_line1) or die("error:  ".mysql_error());
033.            while($arr_line1  = mysql_fetch_array($result_line1)) {
034.                        $an=$arr_line1[BookingTiME_Date];
035.                        $nexplode("-", $an);
036.                        $year=$n[2]."-".$n[1]."-".$n[0];  
037.                ?>         
038.       <option value="<?=$arr_line1[EmpID]?>" <? if($arr_line1[EmpID]==$emp){echo "selected"; }?>  > <?=$arr_line1[EmpName]?>      </option> 
039.            <? } // end while ?>
040.    </select></label></p></td>
041.    </tr>
042.        
043.        <tr height="30"></tr>
044.        <!------เลือกช่าง1------>
045.    <? if($_GET[emp]){ ?>
046.         <?  $total=0;
047.        $total1=0;
048.        $total2=0;
049.        $total3=0;
050.        $total4=0;
051.        $total5=0;
052.        $total6=0;
053.        $total7=0;
054.        $totala=0;
055.        $totala1=0;
056.        $totala2=0;
057.        $totala3=0;
058.        $totala4=0;
059.        $totala5=0;
060.    $count=1;
061.       
062.        $dd = date('d-m-Y');
063.            $year=substr($dd,-4,4);
064.            $nexplode("-",$date);
065.            $dayr=$n[2]."-".$n[1]."-".$n[0];
066.             
067.    for($i=1;$i<=12;$i++){
068.    if(($month==$i)&&($report==6)){ $ai="0".$i;
069.     
070.    $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`
071.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";
072.    }
073.    if($_GET[date]!=""){
074.   $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";  
075.    }
076.        }
077.     
078.    $result2=mysql_query($sql2);
079.     
080.    ?>
081.        <tr class="welcome-message"><td><p>ชื่อช่าง : <? $sql3="select * from employees where EmpID=$emp";
082.                                                 
083.                                                $result3=mysql_query($sql3);
084.                                                $row3=mysql_fetch_array($result3);
085.                                                echo $row3[EmpName];
086.                                                ?></p></td></tr>
087.    <tr><td colspan="6"><b>ตารางรวมผู้ช่วยช่างที่ 1</b></td></tr>
088.    <tr>
089.        <td>ชื่อบริการ</td>
090.        <td width="86">จำนวนบริการ</td>
091.        <td width="48">รวมเงิน</td>
092.        <td width="88">ค่าคอมมิชชั่น</td>
093.        <td width="59">ยอดสุทธิ</td>
094.        <td width="96">เรียงลำดับ</td>
095.             
096.    </tr>
097.   <?
098.     
099.    while($row2=  mysql_fetch_array($result2)){
100.         
101.         
102.     
103.         
104.     ?>
105.    <tr>
106.        <td><? $row2[0];?></td>
107.        <td><? $co=$row2[1]; echo $co;?></td>
108.        <td><? $price=$row2[2]; echo $price; ?></td>
109.        <td><? $com=$row2[3]; $com = round($com,2); echo $com ; ?></td>
110.        <td><? echo $net=$price-$com; ?></td>
111.        <td><?=$count?></td>
112.    </tr>
113.     
114.        <?
115.            $total=$total+$price;
116.            $total1=$total1+$com;
117.            $total2=$total2+$cal;
118.            $total3=$total3+$co;
119.            $totala=$totala+$net;
120.          $count++; } ?>
121.     <tr height="30">
122.        <td></td>
123.        <td></td>
124.        <td></td>
125.        <td></td>
126.        <td></td>
127.        <td></td>
128.    </tr>
129.    <tr>
130.        <td>รวม</td>
131.        <td><?=$total3?></td>
132.        <td><?=$total?></td>
133.        <td><?=$total1?></td>
134.        <td><?=$totala?></td>
135.        <td></td>
136.    </tr>
137.     
138.    <? } ?>  
139.    <!-------------เลือกช่าง 2 --------------->
140.     <tr height="50">
141.        <td></td>
142.        <td></td>
143.        <td></td>
144.        <td></td>
145.        <td></td>
146.        <td></td>
147.    </tr>
148.    <? if($_GET[emp]){ ?>
149.         <? 
150.    $count=1;
151.       
152.        $dd = date('d-m-Y');
153.            $year=substr($dd,-4,4);
154.            $nexplode("-",$date);
155.            $dayr=$n[2]."-".$n[1]."-".$n[0];
156.             
157.    for($i=1;$i<=12;$i++){
158.    if(($month==$i)&&($report==6)){ $ai="0".$i;
159.     
160.    $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`
161.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";
162.    }
163.    if($_GET[date]!=""){
164.   $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";  
165.    }
166.        }
167.     
168.    $result2=mysql_query($sql2);
169.     
170.    ?>
171.    <tr><td colspan="6"><b>ตารางรวมผู้ช่วยช่างที่ 2</b></td></tr>
172.    <tr>
173.        <td>ชื่อบริการ</td>
174.        <td>จำนวนบริการ</td>
175.        <td>รวมเงิน</td>
176.        <td>ค่าคอมมิชชั่น</td>
177.        <td>ยอดสุทธิ</td>
178.        <td>เรียงลำดับ</td>
179.             
180.    </tr>
181.   <?
182.     
183.    while($row2=  mysql_fetch_array($result2)){
184.         
185.     ?>
186.    <tr>
187.        <td><?=$row2[0]?></td>
188.        <td><? $co=$row2[1]; echo $co;?></td>
189.        <td><? $price=$row2[2]; echo $price; ?></td>
190.        <td><? $com=$row2[3]; $com = round($com,2); echo $com ; ?></td>
191.        <td><? echo $net=$price-$com; ?></td>
192.        <td><?=$count?></td>
193.    </tr>
194.     
195.        <?
196.            $totala1=$totala1+$price;
197.            $totala2=$totala2+$com;
198.            $totala3=$totala3+$cal;
199.            $totala4=$totala4+$co;
200.            $totala5=$totala5+$net;
201.          $count++; } ?>
202.     <tr height="30">
203.        <td></td>
204.        <td></td>
205.        <td></td>
206.        <td></td>
207.        <td></td>
208.        <td></td>
209.    </tr>
210.    <tr>
211.        <td>รวม</td>
212.        <td><?=$totala4?></td>
213.        <td><?=$totala1?></td>
214.        <td><?=$totala2?></td>
215.        <td><?=$totala5?></td>
216.        <td></td>
217.    </tr>
218.     
219.     
220.    <tr height="50">
221.        <td></td>
222.        <td></td>
223.        <td></td>
224.        <td></td>
225.        <td></td>
226.        <td></td>
227.    </tr>
228.    <tr>
229.        <td>รวมสุทธิ</td>
230.        <td><? echo $neta1=$total3+$totala4; ?></td>
231.        <td><? echo $neta2=$total+$totala1; ?></td>
232.        <td><? echo $neta3=$total1+$totala2; ?></td>
233.        <td><? echo $neta4=$totala+$totala5; ?></td>
234.        <td></td>  
235.    </tr>
236.    <? } ?>  
237.    <!------------แสดงทั้งหมดผู้ช่วยช่างที่ 1------------------>
238.      <? if($_GET[day]){ ?>
239.          <?    $count=1;
240.        $dd = date('d-m-Y');
241.            $year=substr($dd,-4,4);
242.            $nexplode("-",$date);
243.            $dayr=$n[2]."-".$n[1]."-".$n[0];
244.             
245.    for($i=1;$i<=12;$i++){
246.    if(($month==$i)&&($report==6)){ $ai="0".$i;
247.           $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";
248.    }
249.    if($_GET[date]!=""){
250.        $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";
251.    }
252.    }
253.            
254.            $resultall=mysql_query($sqlall);
255.            $numq=  mysql_num_rows($resultall);
256.            
257.          ?>
258.        <? if($numq!=0){?>
259.         <tr>
260.        <td>ชื่อบริการ</td>
261.        <td>จำนวนบริการ</td>
262.        <td>รวมเงิน</td>
263.         
264.        <td>ค่าคอมมิชชั่น</td>
265.        <td>ยอดสุทธิ</td>
266.        <td>เรียงลำดับ</td>
267.             
268.    </tr>
269.   <?
270.     
271.    while($rowall=mysql_fetch_array($resultall)){
272.     
273.     ?>
274.    <tr>
275.        <td><?=$rowall[0]?></td>
276.        <td><? $co=$rowall[1]; echo $co;?></td>
277.        <td><? $price=$rowall[2]; echo $price; ?></td>
278.        <td><? $com=$rowall[3]; $com = round($com,2); echo $com ; ?></td>
279.        <td><? echo $to=$price-$com; ?>
280.        <td><?=$count?></td>
281.    </tr>
282.     
283.        <?
284.            $total=$total+$price;
285.            $total1=$total1+$com;
286.            $total2=$total2+$cal;
287.            $total3=$total3+$co;
288.          $count++; } ?>
289.      
290.    <tr>
291.        <td>รวม</td>
292.        <td><?=$total3?></td>
293.        <td><?=$total?></td>
294.        <td><?=$total1?></td>
295.        <td><? echo $neta=$total-$total1; ?></td>
296.        <td></td>
297.    </tr>
298.    <tr height="30">
299.        <td></td>
300.        <td></td>
301.        <td></td>
302.        <td></td>
303.        <td></td>
304.        <td></td>
305.    </tr>
306.         
307.         
308.       <?}else{ echo"<tr align='center'><td colspan='6'> No Data</td></tr>";} ?>
309.    <!------------------------------>
310.<!------------แสดงทั้งหมดผู้ช่วยช่างที่ 2------------------>
311.      
312.          <?    $count=1;
313.        $dd = date('d-m-Y');
314.            $year=substr($dd,-4,4);
315.            $nexplode("-",$date);
316.            $dayr=$n[2]."-".$n[1]."-".$n[0];
317.             
318.    for($i=1;$i<=12;$i++){
319.    if(($month==$i)&&($report==6)){ $ai="0".$i;
320.           $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";
321.    }
322.    if($_GET[date]!=""){
323.        $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";
324.    }
325.    }
326.             
327.            $resultall=mysql_query($sqlall);
328.            $numq=  mysql_num_rows($resultall);
329.            
330.          ?>
331.        <? if($numq!=0){?>
332.         <tr>
333.        <td>ชื่อบริการ</td>
334.        <td>จำนวนบริการ</td>
335.        <td>รวมเงิน</td>
336.         
337.        <td>ค่าคอมมิชชั่น</td>
338.        <td>ยอดสุทธิ</td>
339.        <td>เรียงลำดับ</td>
340.             
341.    </tr>
342.   <?
343.     
344.    while($rowall=mysql_fetch_array($resultall)){
345.     
346.     ?>
347.    <tr>
348.        <td><?=$rowall[0]?></td>
349.        <td><? $co=$rowall[1]; echo $co;?></td>
350.        <td><? $price=$rowall[2]; echo $price; ?></td>
351.        <td><? $com=$rowall[3]; $com = round($com,2); echo $com ; ?></td>
352.        <td><? echo $to=$price-$com; ?>
353.        <td><?=$count?></td>
354.    </tr>
355.     
356.        <?
357.            $total4=$total4+$price;
358.            $total5=$total5+$com;
359.            $total6=$total6+$cal;
360.            $total7=$total7+$co;
361.          $count++; } ?>
362.      
363.    <tr>
364.        <td>รวม</td>
365.        <td><?=$total7?></td>
366.        <td><?=$total4?></td>
367.        <td><?=$total5?></td>
368.        <td><? echo $netb=$total4-$total5; ?></td>
369.        <td></td>
370.    </tr>
371.    <tr height="30">
372.        <td></td>
373.        <td></td>
374.        <td></td>
375.        <td></td>
376.        <td></td>
377.        <td></td>
378.    </tr>
379.       <tr>
380.        <td>รวมสุทธิ</td>
381.        <td><? echo $net=$total3+$total7;?></td>
382.        <td><? echo $net1=$total+$total4;?></td>
383.        <td><? echo $net2=$total1+$total5;?></td>
384.        <td><? echo $net3=$neta+$netb;?></td>
385.        <td></td>
386.    </tr>
387.         
388.       <?}else{ echo"<tr align='center'><td colspan='6'> No Data</td></tr>";}  ?>
389.    <!------------------------------>
390.     
391.    <? } ?>
392.</table>
393.  
394.</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 : 1009 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 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)





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