|
|
|
เรียนถามท่านผู้รู้ ดิฉันเก็บข้อมูลใส่ใน array แล้วข้อมูลเป็น 0 แต่ echo ค่ามี ช่วยดูcodeด้วยนะค่ะ |
|
|
|
|
|
|
|
Code (PHP)
$jobtype = array();
for ($i=1; $i<=9; $i++) {
$jobtype[$i][1] = 0; //1 ==> project
$jobtype[$i][2] = 0.00; // 2 ==> amount_project
$jobtype[$i][3] = 0.00; // 3 ==> amount_invoice(แจ้งหนี้)
$jobtype[$i][4] = 0.00; // 4 ==> amount_taxinvoice(รับเงิน)
}
$sql="SELECT o.DeptCode, count(o.ProjectCode), sum(o.Amount), d.DeptName
FROM openproject AS o LEFT JOIN department AS d ON o.DeptCode = d.DeptCode
GROUP BY d.DeptCode, d.DeptName
Order by o.DeptCode ASC";
$tebleopenproject =mysql_query($sql) or die("Error : $sql".mysql_error());
while($data1 = mysql_fetch_array($tebleopenproject)) {
$deptcodeO = $data1["DeptCode"];
$projectO = $data1["1"];
$amountO = $data1["2"];
$deptnameO = $data1["3"];
echo $deptcodeO." ".$projectO." ".$amountO." ".$deptnameO;
if ($jobtype[$i][1] = $data1["1"]);
if ($jobtype[$i][2] = $data1["2"]);
}
$sql ="SELECT ProjectCode, sum(AmountCash)
FROM cashflow
WHERE TypeCode ='A' AND TransType ='I'
GROUP BY ProjectCode,TypeCode, TransType";
$teblecash =mysql_query($sql) or die("Error : $sql".mysql_error());
while($data2 = mysql_fetch_array($teblecash)) {
$projectN = $data2["ProjectCode"];
$amountN = $data2["1"];
echo $projectN." ".$amountN;
if ($jobtype[$i][3] = $data2["1"]);
}
$sql ="SELECT ProjectCode, sum(AmountCash)
FROM cashflow
WHERE TypeCode ='A' AND TransType ='I' AND TaxInvoiceNo <>''
GROUP BY ProjectCode,TypeCode, TransType";
$teblecash1 =mysql_query($sql) or die("Error : $sql".mysql_error());
while($data3 = mysql_fetch_array($teblecash1)) {
$projectC = $data3["ProjectCode"];
$amountC = $data3["1"];
echo $projectC." ".$amountC ;
if ($jobtype[$i][4] = $data3["1"]);
}
?>
<table width="100%" border="1" cellspacing="1" cellpadding="1">
<tr>
<td colspan="9" align="center"><strong>สรุปโครงการ</strong></td>
</tr>
<tr>
<td width="49" align="center"><font size="2">ลำดับ</font></td>
<td width="187" align="center"><font size="2">ฝ่าย</font></td>
<td width="90"align="center"><font size="2">โครงการ</font></td>
<td width="124" align="center"><font size="2">มูลค่าโครงการ</font></td>
<td width="109" align="center"><font size="2">มูลค่าแจ้งหนี้</font></td>
<td width="112" align="center"><font size="2">มูลค่ารับเงิน</font></td>
<td width="118" align="center"><font size="2">มูลค่าค้างรับ</font></td>
<td width="104" align="center"><font size="2">มูลค่าที่ยังไม่แจ้งหนี้</font></td>
<td width="62" align="center"><font size="2"></font> </td>
</tr>
<tr>
<td align="center"><font size="2">1 </font></td>
<td><font size="2">ก่อสร้างสายส่ง1</font></td>
<td align="center"><font size="2"><?php echo $project1 = $jobtype[1][1];?></font> </td>
<td align="right"><font size="2"><?php $amount_pro1 = $jobtype[1][2];
echo number_format($amount_pro1,2);?></font> </td>
<td align="right"><font size="2"><?php $amount_invoice1 = $jobtype[1][3];
echo number_format($amount_invoice1,2); ?></font> </td>
<td align="right"><font size="2"><?php $amount_taxinvoice1 = $jobtype[1][4];
echo number_format($amount_taxinvoice1,2);?></font> </td>
<td align="right"><font size="2"><?php $amount_pend1 =$amount_invoice1-$amount_taxinvoice1;
echo number_format($amount_pend1,2);?></font> </td>
<td align="right"><font size="2"><?php $amount_noinvoice1 =$amount_pro1-$amount_invoice1;
echo number_format($amount_noinvoice1,2);?></font> </td>
<td align="center"><font size="2"><a href="fedit_openproject.php?ProjectCode=<? echo $rowO['ProjectCode'];?>" >แก้ไข</a>
</font></td>
</tr>
<tr>
<td align="center"><font size="2">2 </font></td>
<td><font size="2">ก่อสร้างงานระบบจำหน่าย</font></td>
<td align="center"><font size="2"><?php echo $project2 = $jobtype[2][1];?></font> </td>
<td align="right"><font size="2"><?php $amount_pro2 = $jobtype[2][2];
echo number_format($amount_pro2,2);?></font> </td>
<td align="right"><font size="2"><?php $amount_invoice2 = $jobtype[2][3];
echo number_format($amount_invoice2,2); ?></font> </td>
<td align="right"><font size="2"><?php $amount_taxinvoice2 = $jobtype[2][4];
echo number_format($amount_taxinvoice2,2);?></font> </td>
<td align="right"><font size="2"><?php $amount_pend2 =$amount_invoice2-$amount_taxinvoice2;
echo number_format($amount_pend2,2);?></font> </td>
<td align="right"><font size="2"><?php $amount_noinvoice2 =$amount_pro2-$amount_invoice2;
echo number_format($amount_noinvoice2,2);?></font> </td>
<td align="center"><font size="2"><a href="fedit_openproject.php?ProjectCode=<? echo $rowO['ProjectCode'];?>" >แก้ไข</a>
</font></td>
</tr>
<tr>
<td align="center"><font size="2">3 </font></td>
<td><font size="2">ก่อสร้างสถานีไฟฟ้า3</font></td>
<td align="center"><font size="2"><?php echo $project3 = $jobtype[3][1];?></font> </td>
<td align="right"><font size="2"><?php $amount_pro3 = $jobtype[3][2];
echo number_format($amount_pro3,2);?></font> </td>
<td align="right"><font size="2"><?php $amount_invoice3 = $jobtype[3][3];
echo number_format($amount_invoice3,2); ?></font> </td>
<td align="right"><font size="2"><?php $amount_taxinvoice3 = $jobtype[3][4];
echo number_format($amount_taxinvoice3,2);?></font> </td>
<td align="right"><font size="2"><?php $amount_pend3 =$amount_invoice3-$amount_taxinvoice3;
echo number_format($amount_pend3,2);?></font> </td>
<td align="right"><font size="2"><?php $amount_noinvoice3 =$amount_pro3-$amount_invoice3;
echo number_format($amount_noinvoice3,2);?></font> </td>
<td align="center"><font size="2"><a href="fedit_openproject.php?ProjectCode=<? echo $rowO['ProjectCode'];?>" >แก้ไข</a>
</font></td>
</tr>
<tr>
<td align="center"><font size="2">4 </font></td>
<td><font size="2">ก่อสร้างสถานีไฟฟ้า1</font></td>
<td align="center"><font size="2"><?php echo $project4 = $jobtype[4][1];?></font> </td>
<td align="right"><font size="2"><?php $amount_pro4 = $jobtype[4][2];
echo number_format($amount_pro4,2);?></font> </td>
<td align="right"><font size="2"><?php $amount_invoice4 = $jobtype[4][3];
echo number_format($amount_invoice4,2); ?></font> </td>
<td align="right"><font size="2"><?php $amount_taxinvoice4 = $jobtype[4][4];
echo number_format($amount_taxinvoice4,2);?></font> </td>
<td align="right"><font size="2"><?php $amount_pend4 =$amount_invoice4-$amount_taxinvoice4;
echo number_format($amount_pend4,2);?></font> </td>
<td align="right"><font size="2"><?php $amount_noinvoice4 =$amount_pro4-$amount_invoice4;
echo number_format($amount_noinvoice4,2);?></font> </td>
<td align="center"><font size="2"><a href="fedit_openproject.php?ProjectCode=<? echo $rowO['ProjectCode'];?>" >แก้ไข</a>
</font></td>
</tr>
<tr>
<td align="center"><font size="2">5 </font></td>
<td><font size="2">ก่อสร้างสถานีไฟฟ้า2</font></td>
<td align="center"><font size="2"><?php echo $project5 = $jobtype[5][1];?></font> </td>
<td align="right"><font size="2"><?php $amount_pro5 = $jobtype[5][2];
echo number_format($amount_pro5,2);?></font> </td>
<td align="right"><font size="2"><?php $amount_invoice5 = $jobtype[5][3];
echo number_format($amount_invoice5,2); ?></font> </td>
<td align="right"><font size="2"><?php $amount_taxinvoice5 = $jobtype[5][4];
echo number_format($amount_taxinvoice5,2);?></font> </td>
<td align="right"><font size="2"><?php $amount_pend5 =$amount_invoice5-$amount_taxinvoice5;
echo number_format($amount_pend5,2);?></font> </td>
<td align="right"><font size="2"><?php $amount_noinvoice5 =$amount_pro5-$amount_invoice5;
echo number_format($amount_noinvoice5,2);?></font> </td>
<td align="center"><font size="2"><a href="fedit_openproject.php?ProjectCode=<? echo $rowO['ProjectCode'];?>" >แก้ไข</a>
</font></td>
</tr>
<tr>
<td align="center"><font size="2">6 </font></td>
<td><font size="2">การตลาด</font></td>
<td align="center"><font size="2"><?php echo $project6 = $jobtype[6][1];?></font> </td>
<td align="right"><font size="2"><?php $amount_pro6 = $jobtype[6][2];
echo number_format($amount_pro6,2);?></font> </td>
<td align="right"><font size="2"><?php $amount_invoice6 = $jobtype[6][3];
echo number_format($amount_invoice6,2); ?></font> </td>
<td align="right"><font size="2"><?php $amount_taxinvoice6 = $jobtype[6][4];
echo number_format($amount_taxinvoice6,2);?></font> </td>
<td align="right"><font size="2"><?php $amount_pend6 =$amount_invoice6-$amount_taxinvoice6;
echo number_format($amount_pend6,2);?></font> </td>
<td align="right"><font size="2"><?php $amount_noinvoice6 =$amount_pro6-$amount_invoice6;
echo number_format($amount_noinvoice6,2);?></font> </td>
<td align="center"><font size="2"><a href="fedit_openproject.php?ProjectCode=<? echo $rowO['ProjectCode'];?>" >แก้ไข</a>
</font></td>
</tr>
<tr>
<td align="center"><font size="2">7 </font></td>
<td><font size="2">ก่อสร้างงานระบบ</font></td>
<td align="center"><font size="2"><?php echo $project7 = $jobtype[7][1];?></font> </td>
<td align="right"><font size="2"><?php $amount_pro7 = $jobtype[7][2];
echo number_format($amount_pro7,2);?></font> </td>
<td align="right"><font size="2"><?php $amount_invoice7 = $jobtype[7][3];
echo number_format($amount_invoice7,2); ?></font> </td>
<td align="right"><font size="2"><?php $amount_taxinvoice7 = $jobtype[7][4];
echo number_format($amount_taxinvoice7,2);?></font> </td>
<td align="right"><font size="2"><?php $amount_pend7 =$amount_invoice7-$amount_taxinvoice7;
echo number_format($amount_pend7,2);?></font> </td>
<td align="right"><font size="2"><?php $amount_noinvoice7 =$amount_pro7-$amount_invoice7;
echo number_format($amount_noinvoice7,2);?></font> </td>
<td align="center"><font size="2"><a href="fedit_openproject.php?ProjectCode=<? echo $rowO['ProjectCode'];?>" >แก้ไข</a>
</font></td>
</tr>
<tr>
<td align="center"><font size="2">8 </font></td>
<td><font size="2">สื่อสารและอาณัติสัญญาณ</font></td>
<td align="center"><font size="2"><?php echo $project8 = $jobtype[8][1];?></font> </td>
<td align="right"><font size="2"><?php $amount_pro8 = $jobtype[8][2];
echo number_format($amount_pro8,2);?></font> </td>
<td align="right"><font size="2"><?php $amount_invoice8 = $jobtype[8][3];
echo number_format($amount_invoice8,2); ?></font> </td>
<td align="right"><font size="2"><?php $amount_taxinvoice8 = $jobtype[8][4];
echo number_format($amount_taxinvoice8,2);?></font> </td>
<td align="right"><font size="2"><?php $amount_pend8 =$amount_invoice8-$amount_taxinvoice8;
echo number_format($amount_pend8,2);?></font> </td>
<td align="right"><font size="2"><?php $amount_noinvoice8 =$amount_pro8-$amount_invoice8;
echo number_format($amount_noinvoice8,2);?></font> </td>
<td align="center"><font size="2"><a href="fedit_openproject.php?ProjectCode=<? echo $rowO['ProjectCode'];?>" >แก้ไข</a>
</font></td>
</tr>
<tr>
<td align="center"><font size="2">9 </font></td>
<td><font size="2">ก่อสร้างสายส่ง2</font></td>
<td align="center"><font size="2"><?php echo $project9 = $jobtype[9][1];?></font> </td>
<td align="right"><font size="2"><?php $amount_pro9 = $jobtype[9][2];
echo number_format($amount_pro9,2);?></font> </td>
<td align="right"><font size="2"><?php $amount_invoice9 = $jobtype[9][3];
echo number_format($amount_invoice9,2); ?></font> </td>
<td align="right"><font size="2"><?php $amount_taxinvoice9 = $jobtype[9][4];
echo number_format($amount_taxinvoice9,2);?></font> </td>
<td align="right"><font size="2"><?php $amount_pend9 =$amount_invoice9-$amount_taxinvoice9;
echo number_format($amount_pend9,2);?></font> </td>
<td align="right"><font size="2"><?php $amount_noinvoice9 =$amount_pro9-$amount_invoice9;
echo number_format($amount_noinvoice9,2);?></font> </td>
<td align="center"><font size="2"><a href="fedit_openproject.php?ProjectCode=<? echo $rowO['ProjectCode'];?>" >แก้ไข</a>
</font></td>
</tr>
</table>
Tag : PHP, MySQL, JavaScript, VBScript, CakePHP
|
|
|
|
|
|
Date :
2011-03-02 09:18:02 |
By :
มือใหม่ |
View :
758 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
น่าจะเด่าได้ว่าตำแหน่งของ array ผิดพลาดครับ จะต้องไล่ให้ดีครับ
|
|
|
|
|
Date :
2011-03-02 16:07:22 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|