 |
|
ถามเกียวกับ PHP ครับ อยากเขียนแบบ OOP หรือเวลาแก้ไขโค๊ตจะได้ไม่ต้องไปแก้ไขทุกๆๆหน้าคับ...รบกวนช่วยหน่อยคับ....ผมมือใหม่สมัครเล่นคับ มีโค๊ดอย่างนี้คับ เวลาแก้ไขเมนูไม่อยากต้องไปแก้ไขทุกหน้าครับทำไงคับช่วยบอกหน่อย....พอเป็นแนวทางคับ....
<!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=uft-8" />
<meta http-equiv="Content-Language" content="en" />
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<!-- <META HTTP-EQUIV='Refresh' CONTENT='180; URL=index.php'> สั่ง refresh page auto -->
<meta http-equiv="refresh" content="2;url=javascript:window.close()" />
<title>i-water by Ae.</title>
<style type="text/css">
body {
font: 13px tahoma;
margin: 1em 2em;
}
h1 { font-size: 24px; }
</style>
<link rel="stylesheet" type="text/css" href="example1.css" />
<script type="text/javascript" src="../ie5.js"></script>
<script type="text/javascript" src="DropMenuX.js"></script>
</head>
<body>
<p>
<b>Project by</b>: <a href="http://www.gosu.pl/MyGosuMenu/">MyGosuMenu</a> <br />
<b>Menu type</b>: Version 3.2011.06.01
</p>
<table cellspacing="0" cellpadding="0" id="menu1" class="dmx">
<tr>
<td>
<a class="item1" href="javascript:void(0)">หน้าหลัก</a>
<div class="section">
<a class="item2" href="http://localhost:8088/pos/view/index.php">แสดงยอดขาย</a>
<a class="item2 arrow" href="http://localhost:8088/pos/login/login.php">Login</a>
<a class="item2 arrow" href="javascript:window.close();">Close</a>
</div>
</td>
<td>
<a class="item1" href="javascript:void(0)">ฟังก์ชั่น</a>
<div class="section">
<a class="item2" href="javascript:void(0);">เพิ่มยอด</a>
<div class="section">
<a class="item2 arrow" href="http://localhost:8088/pos/add_data/add_data.php">ขาย</a>
<a class="item2" href="http://localhost:8088/pos/regis/regis_form.php">สมาชิก</a>
<a class="item2 arrow" href="http://localhost:8088/pos/add_user/add_user.php">ลูกค้า</a>
<a class="item2" href="http://localhost:8088/pos/secuerity/admin/insert_form.php">รหัสใช้งาน</a>
</div>
<a class="item2 arrow" href="http://localhost:8088/pos/Exlab/lap_form.php ">ตัวอย่างน้ำ</a>
<a class="item2 arrow" href="http://localhost:8088/pos/commission/commission_form.php ">ติดตามเครื่อง</a>
</div>
</td>
<td>
<a class="item1" href="javascript:void(0)">รายงาน</a>
<div class="section">
<a class="item2" href="http://localhost:8088/pos/view/report/report.php">ยอดขาย</a>
<a class="item2" href="http://localhost:8088/pos/regis/regis_list.php">สมาชิก</a>
<a class="item2 arrow" href="http://localhost:8088/pos/add_user/add_userList.php">ลูกค้า</a>
<a class="item2" href="http://localhost:8088/pos/order/list_report.php">สั่งน้ำ</a>
<a class="item2" href="http://localhost:8088/pos/rent/rent_report.php">ยืมขวด</a>
<a class="item2" href="http://localhost:8088/pos/ViewTeam/view.php">สายงาน</a>
<a class="item2" href="http://localhost:8088/pos/exlab/lap_report.php">ตัวอย่างน้ำ</a>
<a class="item2" href="http://localhost:8088/pos/commission/commission_report.php">ติดตามเครื่อง</a>
</div>
</td>
<td>
<a class="item1" href="javascript:void(0)">อัพเดท</a>
<div class="section">
<a class="item2" href="javascript:void(0);">ยอดขาย</a>
<div class="section">
<a class="item2" href="http://localhost:8088/pos/view/update/EditRecordList.php">อัพเดท</a>
<a class="item2" href="http://localhost:8088/pos/view/delete/DeleteuserList.php?no_id=">ลบ</a>
</div>
<a class="item2" href="javascript:void(0);">สมาชิก</a>
<div class="section">
<a class="item2" href="http://localhost:8088/pos/regis/update/EditRecordList.php">อัพเดท</a>
<a class="item2" href="http://localhost:8088/pos/regis/delete/DeleteUserList.php">ลบ</a>
</div>
<a class="item2" href="javascript:void(0);">ลูกค้า</a>
<div class="section">
<a class="item2" href="http://localhost:8088/pos/add_user/update/editrecordlist.php">อัพเดท</a>
<a class="item2" href="http://localhost:8088/pos/add_user/delete/deleteuserlist.php">ลบ</a>
</div>
<a class="item2" href="javascript:void(0);">สั่งน้ำ</a>
<div class="section">
<a class="item2" href="http://localhost:8088/pos/order/update/EditRecordList.php">อัพเดท</a>
<a class="item2" href="http://localhost:8088/pos/order/delete/DeleteRecordList.php">ลบ</a>
</div>
<a class="item2" href="javascript:void(0);">ยืมขวด</a>
<div class="section">
<a class="item2" href="http://localhost:8088/pos/rent/update/EditRecordList.php">อัพเดท</a>
<a class="item2" href="http://localhost:8088/pos/rent/delete/DeleteRecordList.php">ลบ</a>
</div>
<a class="item2" href="javascript:void(0);">ติดตามเครื่อง</a>
<div class="section">
<a class="item2" href="http://localhost:8088/pos/commission/update/EditRecordList.php">แก้ไข</a>
<a class="item2" href="http://localhost:8088/pos/commission/delete/DeleteRecordList.php">ลบ</a>
</div>
</div>
</td>
<td>
<a class="item1" href="javascript:void(0);">สั่งซื้อ</a>
<div class="section">
<a class="item2" href="http://localhost:8088/pos/phpWebboardCode/NewQuestion.php">กระทู้</a>
<a class="item2" href="http://localhost:8088/pos/phpWebboardCode/NewQuestion.php">สั่งซื้อ</a>
<a class="item2" href="http://localhost:8088/pos/order/order_form.php">สั่งน้ำ</a>
<a class="item2" href="http://localhost:8088/pos/rent/rent_form.php">ยืมขวด</a>
</div>
</td>
<td>
<a class="item1" href="javascript:void(0)">Infomation</a>
<div class="section">
<a class="item2" href="http://localhost:8088/phpMyAdmin/">ฐานข้อมูล</a>
<a class="item2" href="javascript:void(0);">Security</a>
<div class="section">
<a class="item2" href="http://localhost:8088/pos/secuerity/login.php">Admin</a>
<a class="item2" href="javascript:void(0);">User</a>
</div>
</div>
</td>
<td>
<a class="item1" href="javascript:void(0)">เกี่ยวกับเรา</a>
<div class="section">
<a class="item2" href="">เวอร์ชั่น 3.2011.06.1</a>
<a class="item2" href="">ผลิดโดย Mr. Ae Khu.</a>
<a class="item2" href="">ID-0200011857</a>
<a class="item2 arrow" href="javascript:void(0)">ติดต่อ :</a>
<div class="section">
<a class="item2" href="">Tel. 081-4918289</a>
</div>
</div>
</td>
</tr>
</table>
<hr color="009999"/>
<br>
<div align="right" style="color:#ff00ff">
<?php
date_default_timezone_set("Asia/Bangkok");
$date=date('วันที่ '.'d-m-Y '.'เวลา '.'H:i');
echo $date;
?>
</div>
<br>
<fieldset style="width:px; border:1px solid #009999; padding:10"><center><legend>แสดงรายการทั้งหมด</legend>
<br>
<table width="100%" border="0" cellpadding="2" cellspacing="0" bordercolor="#009999">
<tr bgcolor="#009999">
<th><div align="center" name="#"><font face="Tahoma, MS Sans Serif" color="#FFFFFF" ><strong>#</strong></font></div></th>
<th><div align="center" name="date"><font face="Tahoma, MS Sans Serif" color="#FFFFFF"><strong>วันที่</strong></font></div></th>
<th><div align="center" name="code"><font face="Tahoma, MS Sans Serif" color="#FFFFFF"><strong>รหัส</strong></font></div></th>
<th><div align="center" name="name"><font face="Tahoma, MS Sans Serif" color="#FFFFFF"><strong>ชื่อ-สกุล</strong></font></div></th>
<th><div align="center" name="address"><font face="Tahoma, MS Sans Serif" color="#FFFFFF"><strong>ที่อยู่</strong></font></div></th>
<th><div align="center" name="phone"><font face="Tahoma, MS Sans Serif" color="#FFFFFF"><strong>เบอร์ติดต่อ</strong></font></div></th>
<th><div align="center" name="receive"><font face="Tahoma, MS Sans Serif" color="#FFFFFF"><strong>ผู้รับ</div></th>
<th><div align="center" name="recheck"><font face="Tahoma, MS Sans Serif" color="#FFFFFF"><strong>ชำระ</div></th>
<th><div align="center" name="type1"><font face="Tahoma, MS Sans Serif" color="#FFFFFF"><strong>รายการ </strong></font></div></th>
<th><div align="center" name="total1"><font face="Tahoma, MS Sans Serif" color="#FFFFFF"><strong>หน่วย</strong></font></div></th>
<th><div align="center" name="unit1"><font face="Tahoma, MS Sans Serif" color="#FFFFFF"><strong>ประเภท</strong></font></div></th>
<th><div align="center" name="counttotal"><font face="Tahoma, MS Sans Serif" color="#FFFFFF"><strong>จำนวนรับ</strong></font></div></th>
<th><div align="center" name="status"><font face="Tahoma, MS Sans Serif" color="#FFFFFF"><strong>สถานะ</strong></font></div></th>
<th><div align="center" name="price1"><font face="Tahoma, MS Sans Serif" color="#FFFFFF"><strong>ค่าน้ำ</strong></font></div></th>
<th><div align="center" name="price2"><font face="Tahoma, MS Sans Serif" color="#FFFFFF"><strong>ค่าขวด</strong></font></div></th>
<th><div align="center" name="balance"><font face="Tahoma, MS Sans Serif" color="#FFFFFF"><strong>ค้างจ่าย</strong></font></div></th>
<th><div align="center" name="sumprice"><font face="Tahoma, MS Sans Serif" color="#FFFFFF"><strong>ยอดรวม</div></th>
<th><div align="center" name="update"><font face="Tahoma, MS Sans Serif" color="#FFFFFF"><strong>U </div></th>
<th><div align="center" name="delete"><font face="Tahoma, MS Sans Serif" color="#FFFFFF"><strong>D </div></th>
</tr>
<?php
$hostname = "localhost";
$username = "root";
$password = "****";
$dbname = "datadb";
//***********************
$conn = mysql_connect( $hostname, $username, $password );
if ( ! $conn )
die ( "ไม่สามารถติดต่อกับ MySQL ได้" );
mysql_select_db ( $dbname, $conn )
or die ( "ไม่สามารถเลือกฐานข้อมูล school ได้" );
$sqltxt = "SELECT * FROM datatb";
mysql_query("SET character_set_results=tis620");
mysql_query("SET character_set_client=tis620");
mysql_query("SET character_set_connection=tis620");
$result = mysql_query( $sqltxt, $conn);
while ( $res = mysql_fetch_assoc ( $result ) )
{
?>
<tr>
<td><div align="center" style="color:#ff3300"><?php echo $res["no_id"] ?></div></td>
<td><div align="center"><?php echo $res["date"] ?></div></td>
<td><div align="center"><?php echo $res["code"] ?></div></td>
<td><div align="left" style="color:#3333ff"><?php echo $res["name"] ?></div></td>
<td><div align="left" style="color:#3333ff"><?php echo $res["address"] ?></div></td>
<td><div align="right" style="color:#3333ff"><?php echo $res["phone"] ?></div></td>
<td><div align="center" style="color:#009966"><?php echo $res["receive"] ?></div></td>
<td><div align="center" style="color:#ff0099"><?php echo $res["recheck"] ?></div></td>
<td><div align="center" style="color:#ff9900"><?php echo $res["type1"] ?></div></td>
<td><div align="center" style="color:#ff9900"><?php echo $res["total1"] ?></div></td>
<td><div align="center" style="color:#ff9900"><?php echo $res["unit1"] ?></div></td>
<td><div align="center" style="color:#ff9900"><?php echo $res["counttotal"] ?></div></td>
<td><div align="right" style="color:#ff00ff"><?php echo $res["status"] ?></div></td>
<td><div align="center" style="color:#0099cc"><?php echo $res["price1"] ?></div></td>
<td><div align="center" style="color:#0099cc"><?php echo $res["price2"] ?></div></td>
<td><div align="center" style="color:#0099cc"><?php echo $res["balance"] ?></div></td>
<td><div align="center" style="color:#0099cc"><?php echo $res["sumprice"] ?></div></td>
<td><div align="center" style="display:none;"><a href="http://localhost/pos/view/update/EditRecordForm.php?no_id=<?=$res["no_id"];?>">แก้ไข</a></td>
<td><div align="center" style="display:none;"><a href="http://localhost/pos/view/delete/DeleteuserList.php?id=<?=$objResult["id"];?>">ลบ</a></div></td>
</tr>
<?php
}
mysql_free_result($result);
?>
</table>
</form>
</center>
<p>
<script type="text/javascript">
var dmx = new DropMenuX('menu1');
dmx.delay.show = 0;
dmx.delay.hide = 400;
dmx.position.levelX.left = 2;
dmx.init();
</script>
<center>
<?php
$hostname = "localhost";
$username = "root";
$password = "****";
$dbname = "datadb";
$plus = 12;
//***********************
$conn = mysql_connect( $hostname, $username, $password );
if ( ! $conn )
die ( "ไม่สามารถติดต่อกับ MySQL ได้" );
mysql_select_db ( $dbname, $conn )
or die ( "ไม่สามารถเลือกฐานข้อมูล school ได้" );
$sqltxt = "SELECT * FROM datatb";
//sum ผลรวมของค่าจำนวนถังน้ำ
$sql = "select sum(sumprice) as sumprice from datatb";
$result = mysql_query($sql)or die(mysql_error());
$regis = mysql_fetch_array($result);
echo "<center><font size='5' color='#009999'> ยอดสุทธิ : ".$regis['sumprice']."  ฿</font></center>   ";
?>
</fieldset>
<bgsound src="http://localhost:8088/POS/sound/จ่าหรีด อุดร - ซิ่งคอยนาง" ></bgsound>
</center>
</body>
</html>
Tag : PHP, MySQL, CakePHP, Web (ASP.NET), WebService, C#
|
|
 |
 |
 |
 |
Date :
2012-05-20 09:59:46 |
By :
308rifle |
View :
1669 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |