กรุณาช่วยดูให้หน่อยนะฮะ

สำหรับผู้ที่ เริ่มต้น Programming - PHP มีอะไร แนะนำ หรือข้อสงสัยต้องบอร์ด นี้ คนที่มีความรู้ แบ่งปันคนอื่นบ้างนะ ปัญหาการเขียนโปรแกรม แบบ OOP Session Cookies php network

Moderators: mindphp, ผู้ดูแลกระดาน

namenaza
PHP Jr. Member
PHP Jr. Member
Posts: 10
Joined: 01/09/2009 12:54 pm

กรุณาช่วยดูให้หน่อยนะฮะ

Post by namenaza »

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>::ซอฟต์แวร์บริการจัดการร้านขนมขายส่ง::</title>
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {
font-family: AngsanaUPC;
font-size: large;
font-weight: bold;
}
.style4 {
font-size: large;
font-family: AngsanaUPC;
}
-->
</style>
</head>

<body>
<table width="977" hight="30" border="0">
<tr>
<th width="141" height="32" align="left" bgcolor="#f83bce"><img src="pic_snack/ss.JPG" alt="" width="30" height="30" align="absmiddle"/> <a href="home.php?page=dayly1.php" class="style1">สถิติรายวัน</a></th>
<td width="826" rowspan="5" align="left"><table width="826" border="0">
<tr valign="middle" bgcolor="#faf912">
<th width="460" height="32" align="left" valign="middle" bgcolor="#faf912"><img src="pic_snack/thumb_index_icon_numbers20070807.png.jpg" width="30" height="30" align="absmiddle"/> <span class="style1">สถิติการขาย - สถิติรายเดือน</span></th>
<th width="356" align="left" valign="middle" bgcolor="#faf912"><form id="form1" name="form1" method="post" action="home.php?page=monthly.php">
<span class="style5">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="style1">เลือกเดือน</span>
<select name="month" id="month">
<?
if(!$month&&!$year)
{
$month = date("n");
$year = date("Y")+543;
}
$monthname = array("มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน ","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม");
for($i=1;$i<=12;$i++)
{
echo "<option value='$i'";
if($i==$month)
echo "selected = 'selected'";
echo ">".$monthname[$i-1]."</option>";
}
?>
</select>
<select name="year" id="year">
<?
$tyear = date("Y")+543;
for($i=$tyear;$i>=$tyear-5;$i--)
{
echo "<option value='$i'";
if($i==$year)
echo "selected = 'selected'";
echo ">$i</option>";
}
?>
</select>
<input type="submit" name="button" id="button" value="Go">
</form> </th>
</tr>
</table>
<?
if(!$year)

$year = date("Y")+543;
else if (!$month)
$month = date("n");
for($i=1;$i<=12;$i++)
{
$dateall = $i."/".$year;
/*$sql = "SELECT * FROM record WHERE Selldate like '%$dateall'";
$result = mysql_query($sql);
$totalall[$i]=0;
$totalall1[$i]=0;
while($data = mysql_fetch_array($result))
{
$sql = "SELECT * FROM price WHERE ID = '".$data['ID']."'";
$result1 = mysql_query($sql);
$price = mysql_fetch_array($result1);
$totalall[$i]+=$price['Sell_Price']*$data['Amount'];
$totalall1[$i]+=$price['Capital_Price']*$data['Amount'];
}*/

$sql = "SELECT * FROM record WHERE Selldate like '%$dateall'";
$result = mysql_query($sql);
$totalall[$i]=0;
$totalall1[$i]=0;
while($data = mysql_fetch_array($result))
{
$sql = "SELECT * FROM stock WHERE stock_id=".$data["stock_id"];
$result_stock = mysql_query($sql) or die($sql. mysql_error());
$stock = mysql_fetch_array($result_stock);
$totalall[$i]+=$data['Sell_Price']*$data['Amount'];
$totalall1[$i]+=$stock['Capital_Price']*$data['Amount'];
}
}echo $month ,$year;
?>
<table width="465" border="0">
<tr>
<td width="433" height="27">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="style1">กราฟเปรียบเทียบยอดขายแต่ละเดือนในปี <? echo $year; ?></span></td>
</tr>
</table>
<table width="825" border="0">
<tr>
<td width="454" height="251" valign="top"><table width="455" border="0">
<?
for($i=1;$i<=12;$i++)
{ ?>
<tr>
<td width="70" align="center" bgcolor="#F2F2F2"><span class="style1"><? echo $monthname[$i-1]; ?></span></td>
<td width="375" bgcolor="#F2F2F2" valign="middle">
<?
for($j=0;$j<$totalall[$i]/100;$j++)
echo "<img src='pic_snack/footer.gif' width='0.01px' height ='15px' align='absmiddle'>";
echo "<font size = '-2'><strong> ".number_format($totalall[$i])." บาท</strong></font>";
?></td>
</tr>
<? } ?>

</table></td>
<td width="361" valign="top">
<table width="360" border="0">
<tr>
<th width="256" height="29" align="left" bgcolor="#faf912">&nbsp;<img src="pic_snack/327.gif" width="16" height="16" align="absmiddle" /> <span class="style1">5 อันดับขนมขายดีประจำเดือน <? echo $monthname[$month-1]; ?></span></th>
<td width="94" align="center" bgcolor="#faf912"><span class="style1">จำนวน</span></td>
</tr>
<? include("connect.php");
$searchdate = $month."/".$year;
echo $month;
$total=0;
$total1=0;
$sql = "SELECT * FROM record WHERE Selldate like '%$searchdate'";
$result = mysql_query($sql);
while($data = mysql_fetch_array($result))
{
$sql = "SELECT * FROM stock WHERE stock_id=".$data["stock_id"];
$result_stock = mysql_query($sql) or die($sql. mysql_error());
$stock = mysql_fetch_array($result_stock);
$total+=$data['Sell_Price']*$data['Amount'];
$total1+=$stock['Capital_Price']*$data['Amount'];
}

$sql = "SELECT ID,SUM(Amount) as Amount2 FROM record WHERE Selldate like '%$searchdate' GROUP BY id ORDER BY Amount2 DESC";
$result = mysql_query($sql) or die(mysql_error());
$i=1;
while($data = mysql_fetch_array($result))
{
$sql = "SELECT * FROM price WHERE ID = '".$data['ID']."'";
$result1 = mysql_query($sql);
$price = mysql_fetch_array($result1);
//$total+=$price['Sell_Price']*$data['Amount2'];
//$total1+=$price['Capital_Price']*$data['Amount2'];
if($i<=5 && $data['Amount2']>=20)
{
$sql = "SELECT Name,Flavor FROM snack WHERE ID = '".$data['ID']."'";
mysql_query("SET NAMES 'utf8'");
$result1 = mysql_query($sql);
$name = mysql_fetch_array($result1);
//if($data['ID'] == $data['ID'])
?>


<tr>
<td bgcolor="#F2F2F2" > &nbsp;&nbsp;<img src="pic_snack/323.gif" width="18" height="18" /> <span class="style1"><? echo $name['Name'];?>&nbsp;<? echo $name['Flavor'];?></span></td>
<td align="center" bgcolor="#F2F2F2"><span class="style1"><? echo $data['Amount2'];?> ห่อ</span></td>
</tr>

<?
}
$i++;
}echo $month;

?>
</table>
<table width="360" border="0">
<tr>
<th width="256" height="29" align="left" bgcolor="#faf912">
<label>&nbsp;<img src="pic_snack/327.gif" width="16" height="16" align="absmiddle" /> <span class="style1">ขนมที่จำหน่ายทั้งหมดประจำเดือน <? echo $monthname[$month-1]; ?></span><span class="style1"><font size="5" color= "color="#FF0000""><br />
</font></span></label></th>
<td width="94" align="center" bgcolor="#faf912"><span class="style1">จำนวน</span></td>
</tr>
<? include("connect.php");
$searchdate = $month."/".$year;

$total=0;
$total1=0;
$sql = "SELECT * FROM record WHERE Selldate like '%$searchdate'";
$result = mysql_query($sql);
while($data = mysql_fetch_array($result))
{
$sql = "SELECT * FROM stock WHERE stock_id=".$data["stock_id"];
$result_stock = mysql_query($sql) or die($sql. mysql_error());
$stock = mysql_fetch_array($result_stock);
$total+=$data['Sell_Price']*$data['Amount'];
$total1+=$stock['Capital_Price']*$data['Amount'];
}

$sql = "SELECT ID,SUM(Amount) as Amount2 FROM record WHERE Selldate like '%$searchdate' GROUP BY id ORDER BY Amount2 DESC";
$result = mysql_query($sql) or die(mysql_error());
$i=1;
while($data = mysql_fetch_array($result))
{
$sql = "SELECT * FROM price WHERE ID = '".$data['ID']."'";
$result1 = mysql_query($sql);
$price = mysql_fetch_array($result1);
//$total+=$price['Sell_Price']*$data['Amount2'];
//$total1+=$price['Capital_Price']*$data['Amount2'];
if($i<=30 && $data['Amount2']<= 25)
{
$sql = "SELECT Name,Flavor FROM snack WHERE ID = '".$data['ID']."'";
mysql_query("SET NAMES 'utf8'");
$result1 = mysql_query($sql);
$name = mysql_fetch_array($result1);
//if($data['ID'] == $data['ID'])
?>
<tr>
<td bgcolor="#F2F2F2" >&nbsp;&nbsp;<img src="pic_snack/323.gif" width="18" height="18" /> <span class="style1"><? echo $name['Name'];?>&nbsp;<? echo $name['Flavor'];?></span></td>
<td align="center" bgcolor="#F2F2F2"><span class="style1"><? echo $data['Amount2'];?> ห่อ </span></td>
</tr>
<?
}
$i++;
}

?>
</table>

<table width="358" border="0" align="center">
<tr>
<th height="26" colspan="2" align="left" bgcolor="#faf912"><img src="pic_snack/ss.JPG" width="30" height="30" align="absmiddle"/> <span class="style1">สถิติประจำเดือน <? echo $monthname[$month-1]; ?></span></th>
</tr>
<tr>
<td width="253" align="left" bgcolor="#F2F2F2"><span class="style8 style1">&nbsp;&nbsp;&nbsp;&nbsp;<img src="pic_snack/323.gif" width="18" height="18" align="absmiddle" /> ยอดขายประจำเดือน </span></td>
<td width="95" align="center" bgcolor="#F2F2F2"><span class="style1"><? echo number_format($total);?> บาท</span></td>
</tr>
<tr>
<td align="left" bgcolor="#F2F2F2"><span class="style8 style4"><strong>&nbsp;&nbsp;&nbsp;&nbsp;<img src="pic_snack/323.gif" width="18" height="18" align="absmiddle" /> ต้นทุน</strong></span></td>
<td align="center" bgcolor="#F2F2F2"><span class="style1"><? echo number_format($total1);?> บาท</span></td>
</tr>
<tr>
<td align="left" bgcolor="#F2F2F2"><strong>&nbsp;&nbsp;&nbsp;<img src="pic_snack/323.gif" width="18" height="18" align="absmiddle" /><span class="style4"> กำไร</span></strong></td>
<td align="center" bgcolor="#F2F2F2"><span class="style1"><? $pro= $total - $total1; echo number_format($pro);?> บาท</span></td>
</tr>
</table>
</td>
</tr>
</table>

<table width="826" border="0">
<tr bgcolor="#faf912">
<th height="32" colspan="14" align="left"> <img src="pic_snack/ss.JPG" width="30" height="30" align="absmiddle"/><span class="style1"> สถิติแต่ละเดือน</span></th>
</tr>
<tr> </tr>
<tr align="center" bgcolor="#F2F2F2">
<td height="15"><span class="style1">เดือน</span></td>
<td height="15"><span class="style1">ม.ค.</span></td>
<td width="53" height="15"><span class="style1">ก.พ. </span></td>
<td width="53" height="15"><span class="style1">มี.ค.</span></td>
<td width="53" height="15"><span class="style1">เม.ย. </span></td>
<td width="53" height="15"><span class="style1">พ.ค.</span></td>
<td width="53" height="15"><span class="style1">มิ.ย.</span></td>
<td width="53" height="15"><span class="style1">ก.ค.</span></td>
<td width="53" height="15"><span class="style1">ส.ค.</span></td>
<td width="53" height="15"><span class="style1">ก.ย.</span></td>
<td width="53" height="15"><span class="style1">ต.ค</span></td>
<td width="53" height="15"><span class="style1">พ.ย.</span></td>
<td width="53" height="15"><span class="style1">ธ.ค.</span></td>
<td width="65" height="15"><span class="style1">รวม</span></td>
</tr>
<tr bgcolor="#F2F2F2">
<td height="7" align="center"><span class="style1">ยอดขาย</span></td>
<?php
for($i=1;$i<=12;$i++){
//echo $i.'<br>';
}
?>
<?
for($i=1;$i<=12;$i++)
{ ?>
<td width="51" height="7" align="center" bgcolor="#F2F2F2"><span class="style1"><? echo number_format($totalall[$i]); $all +=$totalall[$i];?></span></td>
<? } ?>
<td height="7" align="center" bgcolor="#F2F2F2"><span class="style1"><? echo number_format($all); ?></span></td>
</tr>
<tr bgcolor="#F2F2F2">
<td width="66" height="-1" align="center" bgcolor="#F2F2F2"><span class="style1">ต้นทุน</span></td>
<?
for($i=1;$i<=12;$i++)
{ ?>
<td width="51" height="4" align="center" bgcolor="#F2F2F2"><span class="style1"><? echo number_format($totalall1[$i]); $all1 += $totalall1[$i];?></span></td>
<? } ?>
<td height="4" align="center" bgcolor="#F2F2F2"><span class="style1"><? echo number_format($all1); ?></span></td>
</tr>
<tr bgcolor="#F2F2F2">
<td height="-2" align="center" bgcolor="#F2F2F2"><span class="style1">กำไร</span></td>
<?
for($i=1;$i<=12;$i++)
{ ?>
<td width="51" height="-2" align="center" bgcolor="#F2F2F2"><span class="style1">
<? $all3[$i] = $totalall[$i]-$totalall1[$i]; echo number_format($all3[$i]); $all2 += $all3[$i]; ?>
</span></td>
<? } ?>
<td height="-2" align="center" bgcolor="#F2F2F2"><span class="style1"><? echo number_format($all2); ?></span></td>
</tr>

<tr bgcolor="#F2F2F2"> </tr>

<tr></tr>
</table>
</td>
</tr>
<tr align="left">
<th width="141" height="32" bgcolor="#f83bce"><div align="left"><img src="pic_snack/ss.JPG" width="30" height="30" align="absmiddle"/> <a href="home.php?page=monthly.php" class="style1">สถิติรายเดือน</a></div></th>
</tr>
<tr align="left">
<th width="141" height="32" bgcolor="#f83bce"><div align="left"><img src="pic_snack/ss.JPG" width="30" height="30" align="absmiddle"/> <a href="home.php?page=yeary.php" class="style1">สถิติรายปี</a></div></th>
</tr>
<tr align="left">

</tr>
<tr align="left">
<th width="141" height="305">&nbsp;</th>
</tr>
</table>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
//-->
</script>
</body>
</html>

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

User avatar
ob1
PHP Hero Member
PHP Hero Member
Posts: 185
Joined: 01/01/1970 7:00 am
Contact:

Re: กรุณาช่วยดูให้หน่อยนะฮะ

Post by ob1 »

ผมว่า หัวข้อกระทู้ กรุณาช่วยดูให้หน่อยนะฮะ มันไม่สือเลยนะครับว่าคุณมีปัญหาอะไร
คำถามเดียวกับ
https://www.mindphp.com/forums/viewtopic ... 5013#13724
หรือเปล่าครับ เห็นโค้ดแล้วลายตา แนะนำให้ลองทำเป็นส่วนๆ ส่วนเล็กที่สุดที่พอจะแยกออกไปเขียนได้จะได้รู้ว่า ผิดที่ส่วนใหญ่

Post Reply

Return to “Programming - PHP”

Who is online

Users browsing this forum: dzjp and 20 guests