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 > ขอสอบถามว่า ถ้าเราจะเลือกใน list menu หลายรายการ แล้วมาเปรียบเทียบใน Query ต้องทำยังไงครับ


[PHP] ขอสอบถามว่า ถ้าเราจะเลือกใน list menu หลายรายการ แล้วมาเปรียบเทียบใน Query ต้องทำยังไงครับ

 
Topic : 077329



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



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



ขอสอบถามว่า ถ้าเราจะเลือกใน list menu หลายรายการ แล้วมาเปรียบเทียบใน Query ต้องทำยังไงครับ ตัวอย่าง เช่น เลือกแผนก IT กับ SALES ให้มันแสดงข้อมูลทั้งสองออกมา หรือสามารถได้มั้ยครับว่า ใน list menu มีใฟ้เลือก ALL ได้ก็จะเลือกทั้งหมด ต้องทำยังไงครับ

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

Code ณ ตอนนี้ครับ

Code (PHP)
001.<body>
002.<p align="right">
003. 
004.  <span class="style14">Welcome :
005.  <?=$objResult["U_firstname"];?>   
006.  <? include "menu.php"; ?>
007.</span></p>
008.<form name="frmSearch0" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>">
009.  <table width="100%" border="0" align="center">
010.    <tr>
011.      <th height="52" align="center" valign="top"><script type="text/javascript">
012.AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width', '900','height','34','src','flash/topmenu1','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','flash/topmenu1' ); //end AC code
013.  </script>
014.          <noscript>
015.            <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="900" height="34">
016.            <param name="movie" value="flash/topmenu1.swf">
017.            <param name="quality" value="high">
018.            <embed src="flash/topmenu1.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="900" height="34"></embed>
019.          </object>
020.          </noscript></th>
021.    </tr>
022.    <tr>
023.      <th class="style7">-: Year :-
024.        <select name="year" id="select2">
025.        <option value="<?=$_GET[year];?>" selected>
026.        <?
027.            if($_GET[year]!='')
028.            {
029.                echo $_GET[year];
030.            }
031.            else
032.            {
033.                echo 'Please Select Year';
034.            }
035.        ?></option>
036.          <option>Please Select Year</option>
037.          <option value="2010">2010</option>
038.          <option value="2011">2011</option>
039.          <option value="2012">2012</option>
040.          <option value="2013">2013</option>
041.        </select>
042.        -: Dept :- <span class="style3">
043.        <select name="dept" size="1" multiple id="select" >
044.          <option value="">Please Select Dept.</option>
045.          <option value="00">Center</option>
046.          <option value="01">Purchase</option>
047.          <option value="02">Stock</option>
048.          <option value="03">Sales</option>
049.          <option value="04">Finance</option>
050.          <option value="05">Delivery</option>
051.          <option value="06">OTC</option>
052.          <option value="07">Technician</option>
053.          <option value="08">International</option>
054.          <option value="09">Accounting</option>
055.          <option value="10">Human Resources</option>
056.          <option value="11">R&amp;D</option>
057.          <option value="12">Warehouse</option>
058.          <option value="13">Production</option>
059.          <option value="14">QA</option>
060.          <option value="15">Maintenance</option>
061.          <option value="16">System/Standardization</option>
062.          <option value="17">IT</option>
063.          <option value="18">Management</option>
064.        </select>
065.      </span><span class="style3">
066.      <input type="submit" value="Search">
067.      </span></th>
068.    </tr>
069.  </table>
070.</form>
071. 
072.<?
073.if($_GET["dept"] != "")
074.    {
075. 
076.    $strSQL =
077.     
078.    "SELECT
079.    T2.AcctName,
080.    sum(case month(T0.RefDate) when 1 then (T1.Debit -T1.credit) else 0 end) as 'd01',
081.    sum(case month(T0.RefDate) when 2 then (T1.Debit -T1.credit) else 0 end) as 'd02',
082.    sum(case month(T0.RefDate) when 3 then (T1.Debit -T1.credit) else 0 end) as 'd03',
083.    sum(case month(T0.RefDate) when 4 then (T1.Debit -T1.credit) else 0 end) as 'd04',
084.    sum(case month(T0.RefDate) when 5 then (T1.Debit -T1.credit) else 0 end) as 'd05',
085.    sum(case month(T0.RefDate) when 6 then (T1.Debit -T1.credit) else 0 end) as 'd06',
086.    sum(case month(T0.RefDate) when 7 then (T1.Debit -T1.credit) else 0 end) as 'd07',
087.    sum(case month(T0.RefDate) when 8 then (T1.Debit -T1.credit) else 0 end) as 'd08',
088.    sum(case month(T0.RefDate) when 9 then (T1.Debit -T1.credit) else 0 end) as 'd09',
089.    sum(case month(T0.RefDate) when 10 then (T1.Debit -T1.credit) else 0 end) as 'd10',
090.    sum(case month(T0.RefDate) when 11 then (T1.Debit -T1.credit) else 0 end) as 'd11',
091.    sum(case month(T0.RefDate) when 12 then (T1.Debit -T1.credit) else 0 end) as 'd12'
092.    FROM
093.    OJDT T0 
094.    INNER JOIN JDT1 T1 ON T0.TransId = T1.TransId
095.    INNER JOIN OACT T2 ON T1.Account = T2.AcctCode
096.    WHERE
097.    (T2.segment_0 >= '510000000000' and T2.segment_0  <= '541048010000') and
098.    (T2.segment_1 LIKE '%".$_GET["dept"]."%') AND
099.    (year(T0.RefDate) LIKE '%".$_GET["year"]."%')
100.    GROUP BY 
101.    T2.AcctName
102.    ORDER BY T2.AcctName ASC";
103. 
104.     
105.     
106.    $objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
107. 
108.?>
109. 
110.    <table width="100%" border="1" align="center" cellspacing="0" bordercolor="#000000" bgcolor="#0033FF">
111.      <tr bgcolor="#FF00FF">
112.        <th width="18"><span class="style13">No.</span></th>
113.        <th width="80"><span class="style13">Description</span></th>
114.        <th width="60"><span class="style13">January</span></th>
115.        <th width="60"><span class="style13">February</span></th>
116.        <th width="60"><span class="style13">February</span></th>
117.        <th width="60"><span class="style13">April</span></th>
118.        <th width="60"><span class="style13">May</span></th>
119.        <th width="60"><span class="style13">June</span></th>
120.        <th width="60"><span class="style13">July</span></th>
121.        <th width="60"><span class="style13">August</span></th>
122.        <th width="60"><span class="style13">September</span></th>
123.        <th width="60"><span class="style13">October</span></th>
124.        <th width="60"><span class="style13">November</span></th>
125.        <th width="60"><span class="style13">December</span></th>
126.      </tr>
127.    <?
128.        $i=1;
129.        $j=1;
130.        $intTotal_Debit1 = 0;
131.        $intTotal_Credit1 = 0;
132.        $intTotal_Debit2 = 0;
133.        $intTotal_Credit2 = 0;
134.        $intTotal_Debit3 = 0;
135.        $intTotal_Credit3 = 0;
136.        $intTotal_Debit4 = 0;
137.        $intTotal_Credit4 = 0;
138.        $intTotal_Debit5 = 0;
139.        $intTotal_Credit5 = 0;
140.        $intTotal_Debit6 = 0;
141.        $intTotal_Credit6 = 0;
142.        $intTotal_Debit7 = 0;
143.        $intTotal_Credit7 = 0;
144.        $intTotal_Debit8 = 0;
145.        $intTotal_Credit8 = 0;
146.        $intTotal_Debit9 = 0;
147.        $intTotal_Credit9 = 0;
148.        $intTotal_Debit10 = 0;
149.        $intTotal_Credit10 = 0;
150.        $intTotal_Debit11 = 0;
151.        $intTotal_Credit11 = 0;
152.        $intTotal_Debit12 = 0;
153.        $intTotal_Credit12 = 0;
154.         
155.        while($objResult = mssql_fetch_array($objQuery))
156.        //while($objResult = mssql_fetch_array($objQuery) &&  $objResult2 = mssql_fetch_array($objQuery2))
157.        {
158.     
159.        $intTotal_Debit1 = $intTotal_Debit1 + $objResult["d01"];   
160.        $intTotal_Credit1 = $intTotal_Credit1 + $objResult["c01"];
161.        $intTotal_Debit2 = $intTotal_Debit2 + $objResult["d02"];
162.        $intTotal_Credit2 = $intTotal_Credit2 + $objResult["c02"];
163.        $intTotal_Debit3 = $intTotal_Debit3 + $objResult["d03"];
164.        $intTotal_Credit3 = $intTotal_Credit3 + $objResult["c03"];
165.        $intTotal_Debit4 = $intTotal_Debit4 + $objResult["d04"];
166.        $intTotal_Credit4 = $intTotal_Credit4 + $objResult["c04"];
167.        $intTotal_Debit5 = $intTotal_Debit5 + $objResult["d05"];
168.        $intTotal_Credit5 = $intTotal_Credit5 + $objResult["c05"];
169.        $intTotal_Debit6 = $intTotal_Debit6 + $objResult["d06"];
170.        $intTotal_Credit6 = $intTotal_Credit6 + $objResult["c06"];
171.        $intTotal_Debit7 = $intTotal_Debit7 + $objResult["d07"];
172.        $intTotal_Credit7 = $intTotal_Credit7 + $objResult["c07"];
173.        $intTotal_Debit8 = $intTotal_Debit8 + $objResult["d08"];
174.        $intTotal_Credit8 = $intTotal_Credit8 + $objResult["c08"];
175.        $intTotal_Debit9 = $intTotal_Debit9 + $objResult["d09"];
176.        $intTotal_Credit9 = $intTotal_Credit9 + $objResult["c09"];
177.        $intTotal_Debit10 = $intTotal_Debit10 + $objResult["d10"];
178.        $intTotal_Credit10 = $intTotal_Credit10 + $objResult["c10"];
179.        $intTotal_Debit11 = $intTotal_Debit11 + $objResult["d11"];
180.        $intTotal_Credit11 = $intTotal_Credit11 + $objResult["c11"];
181.        $intTotal_Debit12 = $intTotal_Debit12 + $objResult["d12"];
182.        $intTotal_Credit12 = $intTotal_Credit12 + $objResult["c12"];
183.        $j++;
184.        if($j%2==0)
185.        {
186.            $bg = "#99CCFF";
187.        }
188.        else
189.        {
190.            $bg = "#FFFFFF";
191.        }
192.    ?>
193.    
194.      <tr bgcolor="<?=$bg;?>">
195.        <td><div align="center" class="style8">
196.          <?=$i;?>
197.        </div></td>
198.        <!--<td><div align="left"><span class="style8"><?=$objResult["AcctCode"];?></span></div></td>-->
199.        <td><span class="style8">
200.          <?=$objResult["AcctName"];?>
201.        </span></td>
202.        <td><div align="right"><span class="style8"><?=number_format(substr($objResult["d01"],0,-4),2);?></span></div></td>
203.        <td><div align="right"><span class="style8">
204.          <?=number_format(substr($objResult["d02"],0,-4),2);?>
205.        </span></div></td>
206.        <td><div align="right"><span class="style8">
207.          <?=number_format(substr($objResult["d03"],0,-4),2);?>
208.        </span></div></td>
209.        <td><div align="right"><span class="style8">
210.          <?=number_format(substr($objResult["d04"],0,-4),2);?>
211.        </span></div></td>
212.        <td><div align="right"><span class="style8">
213.          <?=number_format(substr($objResult["d05"],0,-4),2);?>
214.        </span></div></td>
215.        <td><div align="right"><span class="style8">
216.          <?=number_format(substr($objResult["d06"],0,-4),2);?>
217.        </span></div></td>
218.        <td><div align="right"><span class="style8">
219.          <?=number_format(substr($objResult["d07"],0,-4),2);?>
220.        </span></div></td>
221.        <td><div align="right"><span class="style8">
222.          <?=number_format(substr($objResult["d08"],0,-4),2);?>
223.        </span></div></td>
224.        <td><div align="right"><span class="style8">
225.          <?=number_format(substr($objResult["d09"],0,-4),2);?>
226.        </span></div></td>
227.        <td><div align="right"><span class="style8">
228.          <?=number_format(substr($objResult["d10"],0,-4),2);?>
229.        </span></div></td>
230.        <td><div align="right"><span class="style8">
231.          <?=number_format(substr($objResult["d11"],0,-4),2);?>
232.        </span></div></td>
233.        <td><div align="right"><span class="style8">
234.          <?=number_format(substr($objResult["d12"],0,-4),2);?>
235.        </span></div></td>
236.      </tr>
237.       
238.       
239.       
240.    <?
241.        $i++;
242.    }
243.    ?>
244. 
245.       <tr bgcolor="#FFCC33">
246.         <td colspan="2" nowrap="nowrap"><div align="center">ToTal (Expenditure)</div></td>
247.         <td nowrap="nowrap"><div align="right" class="style15">
248.           <?=number_format($intTotal_Debit1,2);?>
249.         </div></td>
250.         <td nowrap="nowrap"><div align="right" class="style15">
251.           <?=number_format($intTotal_Debit2,2);?>
252.         </div></td>
253.         <td nowrap="nowrap"><div align="right" class="style15">
254.           <?=number_format($intTotal_Debit3,2);?>
255.         </div></td>
256.         <td nowrap="nowrap"><div align="right" class="style15">
257.           <?=number_format($intTotal_Debit4,2);?>
258.         </div></td>
259.         <td nowrap="nowrap"><div align="right" class="style15">
260.           <?=number_format($intTotal_Debit5,2);?>
261.         </div></td>
262.         <td nowrap="nowrap"><div align="right" class="style15">
263.           <?=number_format($intTotal_Debit6,2);?>
264.         </div></td>
265.         <td nowrap="nowrap"><div align="right" class="style15">
266.           <?=number_format($intTotal_Debit7,2);?>
267.         </div></td>
268.         <td nowrap="nowrap"><div align="right" class="style15">
269.           <?=number_format($intTotal_Debit8,2);?>
270.         </div></td>
271.         <td nowrap="nowrap"><div align="right" class="style15">
272.           <?=number_format($intTotal_Debit9,2);?>
273.         </div></td>
274.         <td nowrap="nowrap"><div align="right" class="style15">
275.           <?=number_format($intTotal_Debit10,2);?>
276.         </div></td>
277.         <td nowrap="nowrap"><div align="right" class="style15">
278.           <?=number_format($intTotal_Debit11,2);?>
279.         </div></td>
280.         <td nowrap="nowrap"><div align="right" class="style15">
281.           <?=number_format($intTotal_Debit12,2);?>
282.</div></td>
283.       </tr>
284.</table>
285. 
286.    <?
287.        $_GET['SUMDABIT1'] = $intTotal_Debit1;
288.        $_GET['SUMDABIT2'] = $intTotal_Debit2;
289.        $_GET['SUMDABIT3'] = $intTotal_Debit3;
290.        $_GET['SUMDABIT4'] = $intTotal_Debit4;
291.        $_GET['SUMDABIT5'] = $intTotal_Debit5;
292.        $_GET['SUMDABIT6'] = $intTotal_Debit6;
293.        $_GET['SUMDABIT7'] = $intTotal_Debit7;
294.        $_GET['SUMDABIT8'] = $intTotal_Debit8;
295.        $_GET['SUMDABIT9'] = $intTotal_Debit9;
296.        $_GET['SUMDABIT10'] = $intTotal_Debit10;
297.        $_GET['SUMDABIT11'] = $intTotal_Debit11;
298.        $_GET['SUMDABIT12'] = $intTotal_Debit12;
299.    ?>
300.     
301. 
302.     
303.    <br>
304.    <?
305.    mssql_close($objConnect);
306.}
307.?>
308.    <?
309.if($_GET["dept"] != "")
310.    {
311. 
312.    $strSQL =
313.     
314.    "SELECT
315.    T2.AcctName,
316.    sum(case month(T0.RefDate) when 1 then (T1.Credit-T1.Debit) else 0 end) as 'c01',
317.    sum(case month(T0.RefDate) when 2 then (T1.Credit-T1.Debit) else 0 end) as 'c02',
318.    sum(case month(T0.RefDate) when 3 then (T1.Credit-T1.Debit) else 0 end) as 'c03',
319.    sum(case month(T0.RefDate) when 4 then (T1.Credit-T1.Debit) else 0 end) as 'c04',
320.    sum(case month(T0.RefDate) when 5 then (T1.Credit-T1.Debit) else 0 end) as 'c05',
321.    sum(case month(T0.RefDate) when 6 then (T1.Credit-T1.Debit) else 0 end) as 'c06',
322.    sum(case month(T0.RefDate) when 7 then (T1.Credit-T1.Debit) else 0 end) as 'c07',
323.    sum(case month(T0.RefDate) when 8 then (T1.Credit-T1.Debit) else 0 end) as 'c08',
324.    sum(case month(T0.RefDate) when 9 then (T1.Credit-T1.Debit) else 0 end) as 'c09',
325.    sum(case month(T0.RefDate) when 10 then (T1.Credit-T1.Debit) else 0 end) as 'c10',
326.    sum(case month(T0.RefDate) when 11 then (T1.Credit-T1.Debit) else 0 end) as 'c11',
327.    sum(case month(T0.RefDate) when 12 then (T1.Credit-T1.Debit) else 0 end) as 'c12'
328. 
329.    FROM
330.    OJDT T0 
331.    INNER JOIN JDT1 T1 ON T0.TransId = T1.TransId
332.    INNER JOIN OACT T2 ON T1.Account = T2.AcctCode
333.    WHERE
334.    (T2.segment_0 >= '410000000000' and T2.segment_0  <= '43100170000') and
335.    (T2.segment_1 LIKE '%".$_GET["dept"]."%') AND
336.    (year(T0.RefDate) LIKE '%".$_GET["year"]."%')
337.    GROUP BY 
338.    T2.AcctName
339.    ORDER BY T2.AcctName ASC";
340. 
341.     
342.     
343.    $objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
344. 
345.?>
346.<table width="100%" border="1" align="center" cellspacing="0" bordercolor="#000000" bgcolor="#0033FF">
347.      <tr bgcolor="#FF00FF">
348.        <th width="18"><span class="style13">No.</span></th>
349.        <th width="80"><span class="style13">Description</span></th>
350.        <th width="60"><span class="style13">January</span></th>
351.        <th width="60"><span class="style13">February</span></th>
352.        <th width="60"><span class="style13">March</span></th>
353.        <th width="60"><span class="style13">April</span></th>
354.        <th width="60"><span class="style13">May</span></th>
355.        <th width="60"><span class="style13">June</span></th>
356.        <th width="60"><span class="style13">July</span></th>
357.        <th width="60"><span class="style13">August</span></th>
358.        <th width="60"><span class="style13">September</span></th>
359.        <th width="60"><span class="style13">October</span></th>
360.        <th width="60"><span class="style13">November</span></th>
361.        <th width="60"><span class="style13">December</span></th>
362.      </tr>
363.      <?
364.        $i=1;
365.        $j=1;
366.        $intTotal_Debit1 = 0;
367.        $intTotal_Credit1 = 0;
368.        $intTotal_Debit2 = 0;
369.        $intTotal_Credit2 = 0;
370.        $intTotal_Debit3 = 0;
371.        $intTotal_Credit3 = 0;
372.        $intTotal_Debit4 = 0;
373.        $intTotal_Credit4 = 0;
374.        $intTotal_Debit5 = 0;
375.        $intTotal_Credit5 = 0;
376.        $intTotal_Debit6 = 0;
377.        $intTotal_Credit6 = 0;
378.        $intTotal_Debit7 = 0;
379.        $intTotal_Credit7 = 0;
380.        $intTotal_Debit8 = 0;
381.        $intTotal_Credit8 = 0;
382.        $intTotal_Debit9 = 0;
383.        $intTotal_Credit9 = 0;
384.        $intTotal_Debit10 = 0;
385.        $intTotal_Credit10 = 0;
386.        $intTotal_Debit11 = 0;
387.        $intTotal_Credit11 = 0;
388.        $intTotal_Debit12 = 0;
389.        $intTotal_Credit12 = 0;
390.         
391.        while($objResult = mssql_fetch_array($objQuery))
392.        //while($objResult = mssql_fetch_array($objQuery) &&  $objResult2 = mssql_fetch_array($objQuery2))
393.        {
394.     
395.        $intTotal_Debit1 = $intTotal_Debit1 + $objResult["d01"];   
396.        $intTotal_Credit1 = $intTotal_Credit1 + $objResult["c01"];
397.        $intTotal_Debit2 = $intTotal_Debit2 + $objResult["d02"];
398.        $intTotal_Credit2 = $intTotal_Credit2 + $objResult["c02"];
399.        $intTotal_Debit3 = $intTotal_Debit3 + $objResult["d03"];
400.        $intTotal_Credit3 = $intTotal_Credit3 + $objResult["c03"];
401.        $intTotal_Debit4 = $intTotal_Debit4 + $objResult["d04"];
402.        $intTotal_Credit4 = $intTotal_Credit4 + $objResult["c04"];
403.        $intTotal_Debit5 = $intTotal_Debit5 + $objResult["d05"];
404.        $intTotal_Credit5 = $intTotal_Credit5 + $objResult["c05"];
405.        $intTotal_Debit6 = $intTotal_Debit6 + $objResult["d06"];
406.        $intTotal_Credit6 = $intTotal_Credit6 + $objResult["c06"];
407.        $intTotal_Debit7 = $intTotal_Debit7 + $objResult["d07"];
408.        $intTotal_Credit7 = $intTotal_Credit7 + $objResult["c07"];
409.        $intTotal_Debit8 = $intTotal_Debit8 + $objResult["d08"];
410.        $intTotal_Credit8 = $intTotal_Credit8 + $objResult["c08"];
411.        $intTotal_Debit9 = $intTotal_Debit9 + $objResult["d09"];
412.        $intTotal_Credit9 = $intTotal_Credit9 + $objResult["c09"];
413.        $intTotal_Debit10 = $intTotal_Debit10 + $objResult["d10"];
414.        $intTotal_Credit10 = $intTotal_Credit10 + $objResult["c10"];
415.        $intTotal_Debit11 = $intTotal_Debit11 + $objResult["d11"];
416.        $intTotal_Credit11 = $intTotal_Credit11 + $objResult["c11"];
417.        $intTotal_Debit12 = $intTotal_Debit12 + $objResult["d12"];
418.        $intTotal_Credit12 = $intTotal_Credit12 + $objResult["c12"];
419.        $j++;
420.        if($j%2==0)
421.        {
422.            $bg = "#99CCFF";
423.        }
424.        else
425.        {
426.            $bg = "#FFFFFF";
427.        }
428.    ?>
429.      <tr bgcolor="<?=$bg;?>">
430.        <td><div align="center" class="style8">
431.            <?=$i;?>
432.        </div></td>
433.        <!--<td><div align="left"><span class="style8"><?=$objResult["AcctCode"];?></span></div></td>-->
434.        <td><span class="style8">
435.          <?=$objResult["AcctName"];?>
436.        </span></td>
437.        <td><div align="right"><span class="style8">
438.            <?=number_format(substr($objResult["c01"],0,-4),2);?>
439.        </span></div></td>
440.        <td><div align="right"><span class="style8">
441.            <?=number_format(substr($objResult["c02"],0,-4),2);?>
442.        </span></div></td>
443.        <td><div align="right"><span class="style8">
444.            <?=number_format(substr($objResult["c03"],0,-4),2);?>
445.        </span></div></td>
446.        <td><div align="right"><span class="style8">
447.            <?=number_format(substr($objResult["c04"],0,-4),2);?>
448.        </span></div></td>
449.        <td><div align="right"><span class="style8">
450.            <?=number_format(substr($objResult["c05"],0,-4),2);?>
451.        </span></div></td>
452.        <td><div align="right"><span class="style8">
453.            <?=number_format(substr($objResult["c06"],0,-4),2);?>
454.        </span></div></td>
455.        <td><div align="right"><span class="style8">
456.            <?=number_format(substr($objResult["c07"],0,-4),2);?>
457.        </span></div></td>
458.        <td><div align="right"><span class="style8">
459.            <?=number_format(substr($objResult["c08"],0,-4),2);?>
460.        </span></div></td>
461.        <td><div align="right"><span class="style8">
462.            <?=number_format(substr($objResult["c09"],0,-4),2);?>
463.        </span></div></td>
464.        <td><div align="right"><span class="style8">
465.            <?=number_format(substr($objResult["c10"],0,-4),2);?>
466.        </span></div></td>
467.        <td><div align="right"><span class="style8">
468.            <?=number_format(substr($objResult["c11"],0,-4),2);?>
469.        </span></div></td>
470.        <td><div align="right"><span class="style8">
471.            <?=number_format(substr($objResult["c12"],0,-4),2);?>
472.        </span></div></td>
473.      </tr>
474.      <?
475.        $i++;
476.    }
477.    ?>
478.      <tr bgcolor="#FFCC33">
479.        <td colspan="2" nowrap="nowrap"><div align="center">ToTal (Income)</div></td>
480.        <td nowrap="nowrap"><div align="right" class="style15">
481.            <?=number_format($intTotal_Credit1,2);?>
482.        </div></td>
483.        <td nowrap="nowrap"><div align="right" class="style15">
484.            <?=number_format($intTotal_Credit2,2);?>
485.        </div></td>
486.        <td nowrap="nowrap"><div align="right" class="style15">
487.            <?=number_format($intTotal_Credit3,2);?>
488.        </div></td>
489.        <td nowrap="nowrap"><div align="right" class="style15">
490.            <?=number_format($intTotal_Credit4,2);?>
491.        </div></td>
492.        <td nowrap="nowrap"><div align="right" class="style15">
493.            <?=number_format($intTotal_Credit5,2);?>
494.        </div></td>
495.        <td nowrap="nowrap"><div align="right" class="style15">
496.            <?=number_format($intTotal_Credit6,2);?>
497.        </div></td>
498.        <td nowrap="nowrap"><div align="right" class="style15">
499.            <?=number_format($intTotal_Credit7,2);?>
500.        </div></td>
501.        <td nowrap="nowrap"><div align="right" class="style15">
502.            <?=number_format($intTotal_Credit8,2);?>
503.        </div></td>
504.        <td nowrap="nowrap"><div align="right" class="style15">
505.            <?=number_format($intTotal_Credit9,2);?>
506.        </div></td>
507.        <td nowrap="nowrap"><div align="right" class="style15">
508.            <?=number_format($intTotal_Credit10,2);?>
509.        </div></td>
510.        <td nowrap="nowrap"><div align="right" class="style15">
511.            <?=number_format($intTotal_Credit11,2);?>
512.        </div></td>
513.        <td nowrap="nowrap"><div align="right" class="style15">
514.            <?=number_format($intTotal_Credit12,2);?>
515.        </div></td>
516.      </tr>
517.        <?
518.            $_GET['SUMCREDIT1'] = $intTotal_Credit1;
519.            $_GET['SUMCREDIT2'] = $intTotal_Credit2;
520.            $_GET['SUMCREDIT3'] = $intTotal_Credit3;
521.            $_GET['SUMCREDIT4'] = $intTotal_Credit4;
522.            $_GET['SUMCREDIT5'] = $intTotal_Credit5;
523.            $_GET['SUMCREDIT6'] = $intTotal_Credit6;
524.            $_GET['SUMCREDIT7'] = $intTotal_Credit7;
525.            $_GET['SUMCREDIT8'] = $intTotal_Credit8;
526.            $_GET['SUMCREDIT9'] = $intTotal_Credit9;
527.            $_GET['SUMCREDIT10'] = $intTotal_Credit10;
528.            $_GET['SUMCREDIT11'] = $intTotal_Credit11;
529.            $_GET['SUMCREDIT12'] = $intTotal_Credit12;
530.        ?>
531.        <tr bgcolor="#0000FF">
532.          <td colspan="14" nowrap="nowrap">&nbsp;</td>
533.        </tr>
534.      <tr bgcolor="#FFCC33">
535.        <td colspan="2" nowrap="nowrap"><div align="center">ToTal ( Profit, Loss)</div></td>
536.        <td nowrap="nowrap"><div align="right" class="style15">
537.            <? echo number_format(($_GET['SUMCREDIT1']-$_GET['SUMDABIT1']),2);?>
538.        </div></td>
539.        <td nowrap="nowrap"><div align="right" class="style15">
540.            <? echo number_format(($_GET['SUMCREDIT2']-$_GET['SUMDABIT2']),2);?>
541.        </div></td>
542.        <td nowrap="nowrap"><div align="right" class="style15">
543.            <? echo number_format(($_GET['SUMCREDIT3']-$_GET['SUMDABIT3']),2);?>
544.        </div></td>
545.        <td nowrap="nowrap"><div align="right" class="style15">
546.            <? echo number_format(($_GET['SUMCREDIT4']-$_GET['SUMDABIT4']),2);?>
547.        </div></td>
548.        <td nowrap="nowrap"><div align="right" class="style15">
549.            <? echo number_format(($_GET['SUMCREDIT5']-$_GET['SUMDABIT5']),2);?>
550.        </div></td>
551.        <td nowrap="nowrap"><div align="right" class="style15">
552.            <? echo number_format(($_GET['SUMCREDIT6']-$_GET['SUMDABIT6']),2);?>
553.        </div></td>
554.        <td nowrap="nowrap"><div align="right" class="style15">
555.            <? echo number_format(($_GET['SUMCREDIT7']-$_GET['SUMDABIT7']),2);?>
556.        </div></td>
557.        <td nowrap="nowrap"><div align="right" class="style15">
558.            <? echo number_format(($_GET['SUMCREDIT8']-$_GET['SUMDABIT8']),2);?>
559.        </div></td>
560.        <td nowrap="nowrap"><div align="right" class="style15">
561.            <? echo number_format(($_GET['SUMCREDIT9']-$_GET['SUMDABIT9']),2);?>
562.        </div></td>
563.        <td nowrap="nowrap"><div align="right" class="style15">
564.            <? echo number_format(($_GET['SUMCREDIT10']-$_GET['SUMDABIT10']),2);?>
565.        </div></td>
566.        <td nowrap="nowrap"><div align="right" class="style15">
567.            <? echo number_format(($_GET['SUMCREDIT11']-$_GET['SUMDABIT11']),2);?>
568.        </div></td>
569.        <td nowrap="nowrap"><div align="right" class="style15">
570.            <? echo number_format(($_GET['SUMCREDIT12']-$_GET['SUMDABIT12']),2);?>
571.        </div></td>
572.      </tr>
573.    </table>
574.     
575.     
576.     
577.    <br>
578.    <p><?
579.    mssql_close($objConnect);
580.}
581.?>
582.    </p>
583.</body>




Tag : PHP, Ms SQL Server 2005

Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2012-04-21 03:26:57 By : karurub View : 1217 Reply : 8
 

 

No. 1



โพสกระทู้ ( 74,059 )
บทความ ( 838 )

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

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

กรณีเลือกหลายตัว จะต้องเปลี่ยน string ให้อยู่ในรุปแบบที่จะสามารถจำไป IN ใน Statement ได้ครับ เช่น

Code
WHERE Code IN ('1','2')

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-04-21 08:11:38 By : webmaster
 

 

No. 2



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



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


จาก list menu เราต้องกำหนดยังไงครับ

Code (PHP)
01.-: Dept :- <span class="style3">
02.        <select name="dept" size="1" multiple id="select" >
03.          <option value="">Please Select Dept.</option>
04.          <option value="00">Center</option>
05.          <option value="01">Purchase</option>
06.          <option value="02">Stock</option>
07.          <option value="03">Sales</option>
08.          <option value="04">Finance</option>
09.          <option value="05">Delivery</option>
10.          <option value="06">OTC</option>
11.          <option value="07">Technician</option>
12.          <option value="08">International</option>
13.          <option value="09">Accounting</option>
14.          <option value="10">Human Resources</option>
15.          <option value="11">R&amp;D</option>
16.          <option value="12">Warehouse</option>
17.          <option value="13">Production</option>
18.          <option value="14">QA</option>
19.          <option value="15">Maintenance</option>
20.          <option value="16">System/Standardization</option>
21.          <option value="17">IT</option>
22.          <option value="18">Management</option>
23.        </select>
24.      </span><span class="style3">
25.      <input type="submit" value="Search">
26.      </span></th>
27.    </tr>
28.  </table>
29.</form>
30. 
31.<?
32.if($_GET["dept"] != "")
33.    {
34. 
35.    $strSQL =
36.     
37.    "SELECT
38.    T2.AcctName,
39.    sum(case month(T0.RefDate) when 1 then (T1.Debit -T1.credit) else 0 end) as 'd01',
40.    sum(case month(T0.RefDate) when 2 then (T1.Debit -T1.credit) else 0 end) as 'd02',
41.    sum(case month(T0.RefDate) when 3 then (T1.Debit -T1.credit) else 0 end) as 'd03',
42.    sum(case month(T0.RefDate) when 4 then (T1.Debit -T1.credit) else 0 end) as 'd04',
43.    sum(case month(T0.RefDate) when 5 then (T1.Debit -T1.credit) else 0 end) as 'd05',
44.    sum(case month(T0.RefDate) when 6 then (T1.Debit -T1.credit) else 0 end) as 'd06',
45.    sum(case month(T0.RefDate) when 7 then (T1.Debit -T1.credit) else 0 end) as 'd07',
46.    sum(case month(T0.RefDate) when 8 then (T1.Debit -T1.credit) else 0 end) as 'd08',
47.    sum(case month(T0.RefDate) when 9 then (T1.Debit -T1.credit) else 0 end) as 'd09',
48.    sum(case month(T0.RefDate) when 10 then (T1.Debit -T1.credit) else 0 end) as 'd10',
49.    sum(case month(T0.RefDate) when 11 then (T1.Debit -T1.credit) else 0 end) as 'd11',
50.    sum(case month(T0.RefDate) when 12 then (T1.Debit -T1.credit) else 0 end) as 'd12'
51.    FROM
52.    OJDT T0 
53.    INNER JOIN JDT1 T1 ON T0.TransId = T1.TransId
54.    INNER JOIN OACT T2 ON T1.Account = T2.AcctCode
55.    WHERE
56.    (T2.segment_0 >= '510000000000' and T2.segment_0  <= '541048010000') and
57.    (T2.segment_1 LIKE '%".$_GET["dept"]."%') AND
58.    (year(T0.RefDate) LIKE '%".$_GET["year"]."%')
59.    GROUP BY 
60.    T2.AcctName
61.    ORDER BY T2.AcctName ASC";
62. 
63.     
64.     
65.    $objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
66. 
67.?>



ประวัติการแก้ไข
2012-04-21 11:12:22
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-04-21 11:09:45 By : karurub
 

 

No. 3



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



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


แก้ไขยังไงดีครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-04-21 22:34:00 By : karurub
 

 

No. 4



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



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


ช่วยแนะนำด้วยครับ เทพทั้งหลาย
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-04-22 14:21:58 By : karurub
 

 

No. 5



โพสกระทู้ ( 74,059 )
บทความ ( 838 )

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

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

ลองดูตัวอย่างนี้ครับ

Go to : ทำ Search SQL แบบมีหลายเงื่อนไข ช่วยชี้แนะด้วยครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-04-23 06:31:38 By : webmaster
 

 

No. 6



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



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


ถ้าข้อมูลที่จะเลือก มัยอยู่ใน list menu ถ้าเลือกทีละอันมันก็ได้ครับ แต่ถ้าอยากได้เลือกทุกแผนก หรือแผนกไหนบ้าง คิดไม่ออกครับ ดูตัวอย่างที่คุณ วิน ส่งมา ไปต่อไม่ถูกเลย แต่ยังไงก็ขอบคุณนะครับที่ให้ความช่วยเหลือ

<select name="dept" size="1" multiple id="select" >
<option value="">Please Select Dept.</option>
<option value="00">Center</option>
<option value="01">Purchase</option>
<option value="02">Stock</option>
<option value="03">Sales</option>
<option value="04">Finance</option>
<option value="05">Delivery</option>
<option value="06">OTC</option>
<option value="07">Technician</option>
<option value="08">International</option>
<option value="09">Accounting</option>
<option value="10">Human Resources</option>
<option value="11">R&amp;D</option>
<option value="12">Warehouse</option>
<option value="13">Production</option>
<option value="14">QA</option>
<option value="15">Maintenance</option>
<option value="16">System/Standardization</option>
<option value="17">IT</option>
<option value="18">Management</option>
</select>
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-04-23 09:19:26 By : karurub
 

 

No. 7



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



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


ตอนนี้ตรง URL เวลาเราเลือกข้อมูลหลายรายการ มันขึ้นแบบนี้ครับ
&dept=00&dept=01&dept=02&dept=03&dept=04

ทำไงดีครับ &dept มันเหมือนกันเอาไปเปรียบเที่ยบใน query ไม่ได้ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-04-23 10:37:23 By : karurub
 

 

No. 8



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



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


ยังหาทางออกไม่ได้ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-04-24 11:56:06 By : karurub
 

   

ค้นหาข้อมูล


   
 

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