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

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



 

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

 



Topic : 077329



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



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




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

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

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

Code (PHP)
<body>
<p align="right">

  <span class="style14">Welcome : 
  <?=$objResult["U_firstname"];?>    
  <? include "menu.php"; ?>
</span></p>
<form name="frmSearch0" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>">
  <table width="100%" border="0" align="center">
    <tr>
      <th height="52" align="center" valign="top"><script type="text/javascript">
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
  </script>
          <noscript>
            <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">
            <param name="movie" value="flash/topmenu1.swf">
            <param name="quality" value="high">
            <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>
          </object>
          </noscript></th>
    </tr>
    <tr>
      <th class="style7">-: Year :- 
        <select name="year" id="select2">
        <option value="<?=$_GET[year];?>" selected>
		<?
			if($_GET[year]!='') 
			{
				echo $_GET[year]; 
			}
			else
			{ 
				echo 'Please Select Year'; 
			} 
		?></option>
          <option>Please Select Year</option>
          <option value="2010">2010</option>
          <option value="2011">2011</option>
          <option value="2012">2012</option>
          <option value="2013">2013</option>
        </select>
        -: Dept :- <span class="style3">
        <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>
      </span><span class="style3">
      <input type="submit" value="Search">
      </span></th>
    </tr>
  </table>
</form>

<?
if($_GET["dept"] != "")
	{

	$strSQL = 
	
	"SELECT 
	T2.AcctName,
	sum(case month(T0.RefDate) when 1 then (T1.Debit -T1.credit) else 0 end) as 'd01',
	sum(case month(T0.RefDate) when 2 then (T1.Debit -T1.credit) else 0 end) as 'd02',
	sum(case month(T0.RefDate) when 3 then (T1.Debit -T1.credit) else 0 end) as 'd03',
	sum(case month(T0.RefDate) when 4 then (T1.Debit -T1.credit) else 0 end) as 'd04',
	sum(case month(T0.RefDate) when 5 then (T1.Debit -T1.credit) else 0 end) as 'd05',
	sum(case month(T0.RefDate) when 6 then (T1.Debit -T1.credit) else 0 end) as 'd06',
	sum(case month(T0.RefDate) when 7 then (T1.Debit -T1.credit) else 0 end) as 'd07',
	sum(case month(T0.RefDate) when 8 then (T1.Debit -T1.credit) else 0 end) as 'd08',
	sum(case month(T0.RefDate) when 9 then (T1.Debit -T1.credit) else 0 end) as 'd09',
	sum(case month(T0.RefDate) when 10 then (T1.Debit -T1.credit) else 0 end) as 'd10',
	sum(case month(T0.RefDate) when 11 then (T1.Debit -T1.credit) else 0 end) as 'd11',
	sum(case month(T0.RefDate) when 12 then (T1.Debit -T1.credit) else 0 end) as 'd12'
	FROM 
	OJDT T0  
	INNER JOIN JDT1 T1 ON T0.TransId = T1.TransId 
	INNER JOIN OACT T2 ON T1.Account = T2.AcctCode 
	WHERE
	(T2.segment_0 >= '510000000000' and T2.segment_0  <= '541048010000') and
	(T2.segment_1 LIKE '%".$_GET["dept"]."%') AND 
	(year(T0.RefDate) LIKE '%".$_GET["year"]."%') 
	GROUP BY  
	T2.AcctName
	ORDER BY T2.AcctName ASC";

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

?>

	<table width="100%" border="1" align="center" cellspacing="0" bordercolor="#000000" bgcolor="#0033FF">
	  <tr bgcolor="#FF00FF">
        <th width="18"><span class="style13">No.</span></th>
	    <th width="80"><span class="style13">Description</span></th>
	    <th width="60"><span class="style13">January</span></th>
	    <th width="60"><span class="style13">February</span></th>
	    <th width="60"><span class="style13">February</span></th>
        <th width="60"><span class="style13">April</span></th>
        <th width="60"><span class="style13">May</span></th>
        <th width="60"><span class="style13">June</span></th>
        <th width="60"><span class="style13">July</span></th>
        <th width="60"><span class="style13">August</span></th>
        <th width="60"><span class="style13">September</span></th>
        <th width="60"><span class="style13">October</span></th>
        <th width="60"><span class="style13">November</span></th>
        <th width="60"><span class="style13">December</span></th>
	  </tr>
	<?
    	$i=1;
		$j=1;
		$intTotal_Debit1 = 0;
		$intTotal_Credit1 = 0;
		$intTotal_Debit2 = 0;
		$intTotal_Credit2 = 0;
		$intTotal_Debit3 = 0;
		$intTotal_Credit3 = 0;
		$intTotal_Debit4 = 0;
		$intTotal_Credit4 = 0;
		$intTotal_Debit5 = 0;
		$intTotal_Credit5 = 0;
		$intTotal_Debit6 = 0;
		$intTotal_Credit6 = 0;
		$intTotal_Debit7 = 0;
		$intTotal_Credit7 = 0;
		$intTotal_Debit8 = 0;
		$intTotal_Credit8 = 0;
		$intTotal_Debit9 = 0;
		$intTotal_Credit9 = 0;
		$intTotal_Debit10 = 0;
		$intTotal_Credit10 = 0;
		$intTotal_Debit11 = 0;
		$intTotal_Credit11 = 0;
		$intTotal_Debit12 = 0;
		$intTotal_Credit12 = 0;
		
		while($objResult = mssql_fetch_array($objQuery))
		//while($objResult = mssql_fetch_array($objQuery) &&  $objResult2 = mssql_fetch_array($objQuery2))
		{
	
		$intTotal_Debit1 = $intTotal_Debit1 + $objResult["d01"];	
		$intTotal_Credit1 = $intTotal_Credit1 + $objResult["c01"];
		$intTotal_Debit2 = $intTotal_Debit2 + $objResult["d02"];
		$intTotal_Credit2 = $intTotal_Credit2 + $objResult["c02"];
		$intTotal_Debit3 = $intTotal_Debit3 + $objResult["d03"];
		$intTotal_Credit3 = $intTotal_Credit3 + $objResult["c03"];
		$intTotal_Debit4 = $intTotal_Debit4 + $objResult["d04"];
		$intTotal_Credit4 = $intTotal_Credit4 + $objResult["c04"];
		$intTotal_Debit5 = $intTotal_Debit5 + $objResult["d05"];
		$intTotal_Credit5 = $intTotal_Credit5 + $objResult["c05"];
		$intTotal_Debit6 = $intTotal_Debit6 + $objResult["d06"];
		$intTotal_Credit6 = $intTotal_Credit6 + $objResult["c06"];
		$intTotal_Debit7 = $intTotal_Debit7 + $objResult["d07"];
		$intTotal_Credit7 = $intTotal_Credit7 + $objResult["c07"];
		$intTotal_Debit8 = $intTotal_Debit8 + $objResult["d08"];
		$intTotal_Credit8 = $intTotal_Credit8 + $objResult["c08"];
		$intTotal_Debit9 = $intTotal_Debit9 + $objResult["d09"];
		$intTotal_Credit9 = $intTotal_Credit9 + $objResult["c09"];
		$intTotal_Debit10 = $intTotal_Debit10 + $objResult["d10"];
		$intTotal_Credit10 = $intTotal_Credit10 + $objResult["c10"];
		$intTotal_Debit11 = $intTotal_Debit11 + $objResult["d11"];
		$intTotal_Credit11 = $intTotal_Credit11 + $objResult["c11"];
		$intTotal_Debit12 = $intTotal_Debit12 + $objResult["d12"];
		$intTotal_Credit12 = $intTotal_Credit12 + $objResult["c12"];
		$j++;
		if($j%2==0)
		{
			$bg = "#99CCFF";
		}
		else
		{
			$bg = "#FFFFFF";
		}
	?>
   
	  <tr bgcolor="<?=$bg;?>">
		<td><div align="center" class="style8">
		  <?=$i;?>
		</div></td>
        <!--<td><div align="left"><span class="style8"><?=$objResult["AcctCode"];?></span></div></td>-->
		<td><span class="style8">
		  <?=$objResult["AcctName"];?>
		</span></td>
		<td><div align="right"><span class="style8"><?=number_format(substr($objResult["d01"],0,-4),2);?></span></div></td>
		<td><div align="right"><span class="style8">
		  <?=number_format(substr($objResult["d02"],0,-4),2);?>
		</span></div></td>
        <td><div align="right"><span class="style8">
          <?=number_format(substr($objResult["d03"],0,-4),2);?>
        </span></div></td>
		<td><div align="right"><span class="style8">
		  <?=number_format(substr($objResult["d04"],0,-4),2);?>
		</span></div></td>
        <td><div align="right"><span class="style8">
          <?=number_format(substr($objResult["d05"],0,-4),2);?>
        </span></div></td>
		<td><div align="right"><span class="style8">
		  <?=number_format(substr($objResult["d06"],0,-4),2);?>
		</span></div></td>
        <td><div align="right"><span class="style8">
          <?=number_format(substr($objResult["d07"],0,-4),2);?>
        </span></div></td>
		<td><div align="right"><span class="style8">
		  <?=number_format(substr($objResult["d08"],0,-4),2);?>
		</span></div></td>
        <td><div align="right"><span class="style8">
          <?=number_format(substr($objResult["d09"],0,-4),2);?>
        </span></div></td>
		<td><div align="right"><span class="style8">
		  <?=number_format(substr($objResult["d10"],0,-4),2);?>
		</span></div></td>
        <td><div align="right"><span class="style8">
          <?=number_format(substr($objResult["d11"],0,-4),2);?>
        </span></div></td>
		<td><div align="right"><span class="style8">
		  <?=number_format(substr($objResult["d12"],0,-4),2);?>
		</span></div></td>
      </tr>
      
      
      
	<?
		$i++;
	}
	?>

       <tr bgcolor="#FFCC33">
         <td colspan="2" nowrap="nowrap"><div align="center">ToTal (Expenditure)</div></td>
         <td nowrap="nowrap"><div align="right" class="style15">
           <?=number_format($intTotal_Debit1,2);?>
         </div></td>
         <td nowrap="nowrap"><div align="right" class="style15">
           <?=number_format($intTotal_Debit2,2);?>
         </div></td>
         <td nowrap="nowrap"><div align="right" class="style15">
           <?=number_format($intTotal_Debit3,2);?>
         </div></td>
         <td nowrap="nowrap"><div align="right" class="style15">
           <?=number_format($intTotal_Debit4,2);?>
         </div></td>
         <td nowrap="nowrap"><div align="right" class="style15">
           <?=number_format($intTotal_Debit5,2);?>
         </div></td>
         <td nowrap="nowrap"><div align="right" class="style15">
           <?=number_format($intTotal_Debit6,2);?>
         </div></td>
         <td nowrap="nowrap"><div align="right" class="style15">
           <?=number_format($intTotal_Debit7,2);?>
         </div></td>
         <td nowrap="nowrap"><div align="right" class="style15">
           <?=number_format($intTotal_Debit8,2);?>
         </div></td>
         <td nowrap="nowrap"><div align="right" class="style15">
           <?=number_format($intTotal_Debit9,2);?>
         </div></td>
         <td nowrap="nowrap"><div align="right" class="style15">
           <?=number_format($intTotal_Debit10,2);?>
         </div></td>
         <td nowrap="nowrap"><div align="right" class="style15">
           <?=number_format($intTotal_Debit11,2);?>
         </div></td>
         <td nowrap="nowrap"><div align="right" class="style15">
           <?=number_format($intTotal_Debit12,2);?>
</div></td>
       </tr>
</table>

	<? 
		$_GET['SUMDABIT1'] = $intTotal_Debit1;
		$_GET['SUMDABIT2'] = $intTotal_Debit2;
		$_GET['SUMDABIT3'] = $intTotal_Debit3;
		$_GET['SUMDABIT4'] = $intTotal_Debit4;
		$_GET['SUMDABIT5'] = $intTotal_Debit5;
		$_GET['SUMDABIT6'] = $intTotal_Debit6;
		$_GET['SUMDABIT7'] = $intTotal_Debit7;
		$_GET['SUMDABIT8'] = $intTotal_Debit8;
		$_GET['SUMDABIT9'] = $intTotal_Debit9;
		$_GET['SUMDABIT10'] = $intTotal_Debit10;
		$_GET['SUMDABIT11'] = $intTotal_Debit11;
		$_GET['SUMDABIT12'] = $intTotal_Debit12;
	?>
    

    
    <br>
    <?
	mssql_close($objConnect);
}
?>
    <?
if($_GET["dept"] != "")
	{

	$strSQL = 
	
	"SELECT 
	T2.AcctName,
	sum(case month(T0.RefDate) when 1 then (T1.Credit-T1.Debit) else 0 end) as 'c01',
	sum(case month(T0.RefDate) when 2 then (T1.Credit-T1.Debit) else 0 end) as 'c02',
	sum(case month(T0.RefDate) when 3 then (T1.Credit-T1.Debit) else 0 end) as 'c03',
	sum(case month(T0.RefDate) when 4 then (T1.Credit-T1.Debit) else 0 end) as 'c04',
	sum(case month(T0.RefDate) when 5 then (T1.Credit-T1.Debit) else 0 end) as 'c05',
	sum(case month(T0.RefDate) when 6 then (T1.Credit-T1.Debit) else 0 end) as 'c06',
	sum(case month(T0.RefDate) when 7 then (T1.Credit-T1.Debit) else 0 end) as 'c07',
	sum(case month(T0.RefDate) when 8 then (T1.Credit-T1.Debit) else 0 end) as 'c08',
	sum(case month(T0.RefDate) when 9 then (T1.Credit-T1.Debit) else 0 end) as 'c09',
	sum(case month(T0.RefDate) when 10 then (T1.Credit-T1.Debit) else 0 end) as 'c10',
	sum(case month(T0.RefDate) when 11 then (T1.Credit-T1.Debit) else 0 end) as 'c11',
	sum(case month(T0.RefDate) when 12 then (T1.Credit-T1.Debit) else 0 end) as 'c12'

	FROM 
	OJDT T0  
	INNER JOIN JDT1 T1 ON T0.TransId = T1.TransId 
	INNER JOIN OACT T2 ON T1.Account = T2.AcctCode 
	WHERE
	(T2.segment_0 >= '410000000000' and T2.segment_0  <= '43100170000') and
	(T2.segment_1 LIKE '%".$_GET["dept"]."%') AND 
	(year(T0.RefDate) LIKE '%".$_GET["year"]."%') 
	GROUP BY  
	T2.AcctName
	ORDER BY T2.AcctName ASC";

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

?>
<table width="100%" border="1" align="center" cellspacing="0" bordercolor="#000000" bgcolor="#0033FF">
      <tr bgcolor="#FF00FF">
        <th width="18"><span class="style13">No.</span></th>
        <th width="80"><span class="style13">Description</span></th>
        <th width="60"><span class="style13">January</span></th>
        <th width="60"><span class="style13">February</span></th>
        <th width="60"><span class="style13">March</span></th>
        <th width="60"><span class="style13">April</span></th>
        <th width="60"><span class="style13">May</span></th>
        <th width="60"><span class="style13">June</span></th>
        <th width="60"><span class="style13">July</span></th>
        <th width="60"><span class="style13">August</span></th>
        <th width="60"><span class="style13">September</span></th>
        <th width="60"><span class="style13">October</span></th>
        <th width="60"><span class="style13">November</span></th>
        <th width="60"><span class="style13">December</span></th>
      </tr>
      <?
    	$i=1;
		$j=1;
		$intTotal_Debit1 = 0;
		$intTotal_Credit1 = 0;
		$intTotal_Debit2 = 0;
		$intTotal_Credit2 = 0;
		$intTotal_Debit3 = 0;
		$intTotal_Credit3 = 0;
		$intTotal_Debit4 = 0;
		$intTotal_Credit4 = 0;
		$intTotal_Debit5 = 0;
		$intTotal_Credit5 = 0;
		$intTotal_Debit6 = 0;
		$intTotal_Credit6 = 0;
		$intTotal_Debit7 = 0;
		$intTotal_Credit7 = 0;
		$intTotal_Debit8 = 0;
		$intTotal_Credit8 = 0;
		$intTotal_Debit9 = 0;
		$intTotal_Credit9 = 0;
		$intTotal_Debit10 = 0;
		$intTotal_Credit10 = 0;
		$intTotal_Debit11 = 0;
		$intTotal_Credit11 = 0;
		$intTotal_Debit12 = 0;
		$intTotal_Credit12 = 0;
		
		while($objResult = mssql_fetch_array($objQuery))
		//while($objResult = mssql_fetch_array($objQuery) &&  $objResult2 = mssql_fetch_array($objQuery2))
		{
	
		$intTotal_Debit1 = $intTotal_Debit1 + $objResult["d01"];	
		$intTotal_Credit1 = $intTotal_Credit1 + $objResult["c01"];
		$intTotal_Debit2 = $intTotal_Debit2 + $objResult["d02"];
		$intTotal_Credit2 = $intTotal_Credit2 + $objResult["c02"];
		$intTotal_Debit3 = $intTotal_Debit3 + $objResult["d03"];
		$intTotal_Credit3 = $intTotal_Credit3 + $objResult["c03"];
		$intTotal_Debit4 = $intTotal_Debit4 + $objResult["d04"];
		$intTotal_Credit4 = $intTotal_Credit4 + $objResult["c04"];
		$intTotal_Debit5 = $intTotal_Debit5 + $objResult["d05"];
		$intTotal_Credit5 = $intTotal_Credit5 + $objResult["c05"];
		$intTotal_Debit6 = $intTotal_Debit6 + $objResult["d06"];
		$intTotal_Credit6 = $intTotal_Credit6 + $objResult["c06"];
		$intTotal_Debit7 = $intTotal_Debit7 + $objResult["d07"];
		$intTotal_Credit7 = $intTotal_Credit7 + $objResult["c07"];
		$intTotal_Debit8 = $intTotal_Debit8 + $objResult["d08"];
		$intTotal_Credit8 = $intTotal_Credit8 + $objResult["c08"];
		$intTotal_Debit9 = $intTotal_Debit9 + $objResult["d09"];
		$intTotal_Credit9 = $intTotal_Credit9 + $objResult["c09"];
		$intTotal_Debit10 = $intTotal_Debit10 + $objResult["d10"];
		$intTotal_Credit10 = $intTotal_Credit10 + $objResult["c10"];
		$intTotal_Debit11 = $intTotal_Debit11 + $objResult["d11"];
		$intTotal_Credit11 = $intTotal_Credit11 + $objResult["c11"];
		$intTotal_Debit12 = $intTotal_Debit12 + $objResult["d12"];
		$intTotal_Credit12 = $intTotal_Credit12 + $objResult["c12"];
		$j++;
		if($j%2==0)
		{
			$bg = "#99CCFF";
		}
		else
		{
			$bg = "#FFFFFF";
		}
	?>
      <tr bgcolor="<?=$bg;?>">
        <td><div align="center" class="style8">
            <?=$i;?>
        </div></td>
        <!--<td><div align="left"><span class="style8"><?=$objResult["AcctCode"];?></span></div></td>-->
        <td><span class="style8">
          <?=$objResult["AcctName"];?>
        </span></td>
        <td><div align="right"><span class="style8">
            <?=number_format(substr($objResult["c01"],0,-4),2);?>
        </span></div></td>
        <td><div align="right"><span class="style8">
            <?=number_format(substr($objResult["c02"],0,-4),2);?>
        </span></div></td>
        <td><div align="right"><span class="style8">
            <?=number_format(substr($objResult["c03"],0,-4),2);?>
        </span></div></td>
        <td><div align="right"><span class="style8">
            <?=number_format(substr($objResult["c04"],0,-4),2);?>
        </span></div></td>
        <td><div align="right"><span class="style8">
            <?=number_format(substr($objResult["c05"],0,-4),2);?>
        </span></div></td>
        <td><div align="right"><span class="style8">
            <?=number_format(substr($objResult["c06"],0,-4),2);?>
        </span></div></td>
        <td><div align="right"><span class="style8">
            <?=number_format(substr($objResult["c07"],0,-4),2);?>
        </span></div></td>
        <td><div align="right"><span class="style8">
            <?=number_format(substr($objResult["c08"],0,-4),2);?>
        </span></div></td>
        <td><div align="right"><span class="style8">
            <?=number_format(substr($objResult["c09"],0,-4),2);?>
        </span></div></td>
        <td><div align="right"><span class="style8">
            <?=number_format(substr($objResult["c10"],0,-4),2);?>
        </span></div></td>
        <td><div align="right"><span class="style8">
            <?=number_format(substr($objResult["c11"],0,-4),2);?>
        </span></div></td>
        <td><div align="right"><span class="style8">
            <?=number_format(substr($objResult["c12"],0,-4),2);?>
        </span></div></td>
      </tr>
      <?
		$i++;
	}
	?>
      <tr bgcolor="#FFCC33">
        <td colspan="2" nowrap="nowrap"><div align="center">ToTal (Income)</div></td>
        <td nowrap="nowrap"><div align="right" class="style15">
            <?=number_format($intTotal_Credit1,2);?>
        </div></td>
        <td nowrap="nowrap"><div align="right" class="style15">
            <?=number_format($intTotal_Credit2,2);?>
        </div></td>
        <td nowrap="nowrap"><div align="right" class="style15">
            <?=number_format($intTotal_Credit3,2);?>
        </div></td>
        <td nowrap="nowrap"><div align="right" class="style15">
            <?=number_format($intTotal_Credit4,2);?>
        </div></td>
        <td nowrap="nowrap"><div align="right" class="style15">
            <?=number_format($intTotal_Credit5,2);?>
        </div></td>
        <td nowrap="nowrap"><div align="right" class="style15">
            <?=number_format($intTotal_Credit6,2);?>
        </div></td>
        <td nowrap="nowrap"><div align="right" class="style15">
            <?=number_format($intTotal_Credit7,2);?>
        </div></td>
        <td nowrap="nowrap"><div align="right" class="style15">
            <?=number_format($intTotal_Credit8,2);?>
        </div></td>
        <td nowrap="nowrap"><div align="right" class="style15">
            <?=number_format($intTotal_Credit9,2);?>
        </div></td>
        <td nowrap="nowrap"><div align="right" class="style15">
            <?=number_format($intTotal_Credit10,2);?>
        </div></td>
        <td nowrap="nowrap"><div align="right" class="style15">
            <?=number_format($intTotal_Credit11,2);?>
        </div></td>
        <td nowrap="nowrap"><div align="right" class="style15">
            <?=number_format($intTotal_Credit12,2);?>
        </div></td>
      </tr>
		<?
			$_GET['SUMCREDIT1'] = $intTotal_Credit1;
			$_GET['SUMCREDIT2'] = $intTotal_Credit2;
			$_GET['SUMCREDIT3'] = $intTotal_Credit3;
			$_GET['SUMCREDIT4'] = $intTotal_Credit4;
			$_GET['SUMCREDIT5'] = $intTotal_Credit5;
			$_GET['SUMCREDIT6'] = $intTotal_Credit6;
			$_GET['SUMCREDIT7'] = $intTotal_Credit7;
			$_GET['SUMCREDIT8'] = $intTotal_Credit8;
			$_GET['SUMCREDIT9'] = $intTotal_Credit9;
			$_GET['SUMCREDIT10'] = $intTotal_Credit10;
			$_GET['SUMCREDIT11'] = $intTotal_Credit11;
			$_GET['SUMCREDIT12'] = $intTotal_Credit12;
		?>
        <tr bgcolor="#0000FF">
          <td colspan="14" nowrap="nowrap">&nbsp;</td>
        </tr>
      <tr bgcolor="#FFCC33">
        <td colspan="2" nowrap="nowrap"><div align="center">ToTal ( Profit, Loss)</div></td>
        <td nowrap="nowrap"><div align="right" class="style15">
            <? echo number_format(($_GET['SUMCREDIT1']-$_GET['SUMDABIT1']),2);?>
        </div></td>
        <td nowrap="nowrap"><div align="right" class="style15">
            <? echo number_format(($_GET['SUMCREDIT2']-$_GET['SUMDABIT2']),2);?>
        </div></td>
        <td nowrap="nowrap"><div align="right" class="style15">
            <? echo number_format(($_GET['SUMCREDIT3']-$_GET['SUMDABIT3']),2);?>
        </div></td>
        <td nowrap="nowrap"><div align="right" class="style15">
            <? echo number_format(($_GET['SUMCREDIT4']-$_GET['SUMDABIT4']),2);?>
        </div></td>
        <td nowrap="nowrap"><div align="right" class="style15">
            <? echo number_format(($_GET['SUMCREDIT5']-$_GET['SUMDABIT5']),2);?>
        </div></td>
        <td nowrap="nowrap"><div align="right" class="style15">
            <? echo number_format(($_GET['SUMCREDIT6']-$_GET['SUMDABIT6']),2);?>
        </div></td>
        <td nowrap="nowrap"><div align="right" class="style15">
            <? echo number_format(($_GET['SUMCREDIT7']-$_GET['SUMDABIT7']),2);?>
        </div></td>
        <td nowrap="nowrap"><div align="right" class="style15">
            <? echo number_format(($_GET['SUMCREDIT8']-$_GET['SUMDABIT8']),2);?>
        </div></td>
        <td nowrap="nowrap"><div align="right" class="style15">
            <? echo number_format(($_GET['SUMCREDIT9']-$_GET['SUMDABIT9']),2);?>
        </div></td>
        <td nowrap="nowrap"><div align="right" class="style15">
            <? echo number_format(($_GET['SUMCREDIT10']-$_GET['SUMDABIT10']),2);?>
        </div></td>
        <td nowrap="nowrap"><div align="right" class="style15">
            <? echo number_format(($_GET['SUMCREDIT11']-$_GET['SUMDABIT11']),2);?>
        </div></td>
        <td nowrap="nowrap"><div align="right" class="style15">
            <? echo number_format(($_GET['SUMCREDIT12']-$_GET['SUMDABIT12']),2);?>
        </div></td>
      </tr>
    </table>
    
    
    
    <br>
    <p><?
	mssql_close($objConnect);
}
?>
    </p>
</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 : 1154 Reply : 8
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 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)
-: Dept :- <span class="style3">
        <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>
      </span><span class="style3">
      <input type="submit" value="Search">
      </span></th>
    </tr>
  </table>
</form>

<?
if($_GET["dept"] != "")
	{

	$strSQL = 
	
	"SELECT 
	T2.AcctName,
	sum(case month(T0.RefDate) when 1 then (T1.Debit -T1.credit) else 0 end) as 'd01',
	sum(case month(T0.RefDate) when 2 then (T1.Debit -T1.credit) else 0 end) as 'd02',
	sum(case month(T0.RefDate) when 3 then (T1.Debit -T1.credit) else 0 end) as 'd03',
	sum(case month(T0.RefDate) when 4 then (T1.Debit -T1.credit) else 0 end) as 'd04',
	sum(case month(T0.RefDate) when 5 then (T1.Debit -T1.credit) else 0 end) as 'd05',
	sum(case month(T0.RefDate) when 6 then (T1.Debit -T1.credit) else 0 end) as 'd06',
	sum(case month(T0.RefDate) when 7 then (T1.Debit -T1.credit) else 0 end) as 'd07',
	sum(case month(T0.RefDate) when 8 then (T1.Debit -T1.credit) else 0 end) as 'd08',
	sum(case month(T0.RefDate) when 9 then (T1.Debit -T1.credit) else 0 end) as 'd09',
	sum(case month(T0.RefDate) when 10 then (T1.Debit -T1.credit) else 0 end) as 'd10',
	sum(case month(T0.RefDate) when 11 then (T1.Debit -T1.credit) else 0 end) as 'd11',
	sum(case month(T0.RefDate) when 12 then (T1.Debit -T1.credit) else 0 end) as 'd12'
	FROM 
	OJDT T0  
	INNER JOIN JDT1 T1 ON T0.TransId = T1.TransId 
	INNER JOIN OACT T2 ON T1.Account = T2.AcctCode 
	WHERE
	(T2.segment_0 >= '510000000000' and T2.segment_0  <= '541048010000') and
	(T2.segment_1 LIKE '%".$_GET["dept"]."%') AND 
	(year(T0.RefDate) LIKE '%".$_GET["year"]."%') 
	GROUP BY  
	T2.AcctName
	ORDER BY T2.AcctName ASC";

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

?>



ประวัติการแก้ไข
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,058 )
บทความ ( 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 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







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

Load balance : Server 05
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 อัตราราคา คลิกที่นี่