|
|
|
ช่วยดูให้หน่อยงงมาก อยากให้มัน ทำฟรอมดึงฐานข้อมูลดึงได้แค่ตารางเดียวช่วยดูโค๊ดให้ที |
|
|
|
|
|
|
|
ช่วยดูให้หน่อยงงมาก อยากให้มัน ทำฟรอมดึงฐานข้อมูลดึงได้แค่ตารางเดียวช่วยดูโค๊ดให้ที
ช่วยแก้ให้ทีคับ มันขึ้นแค่ตารางเดียว ไม่รู้ว่าจะใส่คำสั่งไหนเพิ่มดีมีไฟล์ sql ให้ทดลองด้วยคับ
Code (PHP)
<!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=windows-874" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- TemplateEndEditable -->
<!-- TemplateBeginEditable name="head" -->
<!-- TemplateEndEditable -->
</head>
<body>
<p> </p>
<?php
mysql_connect("localhost", "root", "test") or die(mysql_error());
mysql_select_db(testmember) or die(mysql_error());
$yesterday= "06.05.11";
$today="10.05.11";
$data = mysql_query("SELECT * FROM status WHERE datetime >='$yesterday' AND datetime<='$today'") or die(mysql_error());
print "<table width='100' border='1' cellpadding='0' cellspacing='0'>";
print "<td width='90' height='26' bgcolor='#99FF99'><div align='center'><strong>Nitrogen Tank No.</strong></div></td>";
print "</tr>";
for ($i = 1; $i <= 12; )
{
print "<tr height='33'>";
print "<td height='33' bgcolor='#99FF99'><div align='center'><strong>No.".$i."</strong></div></td>";
while($info = mysql_fetch_array( $data ))
{
print "<td height='33' bgcolor='#99FF99'><div align='center'><strong>".$info[no.$i]."</strong></div></td>";
}
$i++;
}
print "</tr>";
print "</tr>";
print "</table>";
print "</body>";
?>
</html>
ส่วนนี่คือไฟล์ sql
Code (PHP)
-- phpMyAdmin SQL Dump
-- version 2.10.3
-- http://www.phpmyadmin.net
--
-- โฮสต์: localhost
-- เวลาในการสร้าง: 10 พ.ค. 2011 น.
-- รุ่นของเซิร์ฟเวอร์: 6.0.4
-- รุ่นของ PHP: 6.0.0-dev
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- ฐานข้อมูล: `testmember`
--
-- --------------------------------------------------------
--
-- โครงสร้างตาราง `status`
--
CREATE TABLE `status` (
`no1` varchar(14) NOT NULL,
`no2` varchar(14) NOT NULL,
`no3` varchar(14) NOT NULL,
`no4` varchar(14) NOT NULL,
`no5` varchar(14) NOT NULL,
`no6` varchar(14) NOT NULL,
`no7` varchar(14) NOT NULL,
`no8` varchar(14) NOT NULL,
`no9` varchar(14) NOT NULL,
`no10` varchar(14) NOT NULL,
`no11` varchar(14) NOT NULL,
`no12` varchar(14) NOT NULL,
`no13` varchar(14) NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`datetime` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- dump ตาราง `status`
--
INSERT INTO `status` VALUES ('Used', 'Empty', 'Spare', 'Empty', 'Empty', 'Empty', 'Used', 'Spare', 'Empty', '', '', '', '', '2011-05-06 13:49:51', '06.05.11');
INSERT INTO `status` VALUES ('Spare', 'Tank Damage', 'Empty', 'Spare', 'Spare', 'Spare', 'Spare', 'Used', 'Spare', 'Empty', 'Spare', 'Spare', '', '2011-05-09 17:50:09', '09.05.11');
INSERT INTO `status` VALUES ('Spare', 'Used', 'Tank Damage', 'Used', 'Used', 'Used', 'Used', 'Used', 'Spare', 'Used', 'Spare', 'Used', '', '2011-05-09 13:22:44', '09.05.11');
INSERT INTO `status` VALUES ('Spare', 'Tank Damage', 'Empty', 'Spare', 'Spare', 'Spare', 'Spare', 'Used', 'Spare', 'Empty', 'Spare', 'Spare', '', '2011-05-09 17:52:43', '09.05.11');
INSERT INTO `status` VALUES ('Used', 'Spare', 'Empty', 'Empty', 'Tank Damage', 'Used', 'Empty', 'Empty', 'Empty', 'Tank Damage', 'Empty', 'Used', '', '2011-05-10 12:33:02', '10.05.11');
INSERT INTO `status` VALUES ('Used', 'Spare', 'Empty', 'Empty', 'Tank Damage', 'Used', 'Empty', 'Empty', 'Empty', 'Tank Damage', 'Empty', 'Used', '', '2011-05-10 12:33:05', '10.05.11');
INSERT INTO `status` VALUES ('Used', 'Spare', 'Empty', 'Empty', 'Tank Damage', 'Used', 'Empty', 'Empty', 'Empty', 'Tank Damage', 'Empty', 'Used', '', '2011-05-10 12:33:09', '10.05.11');
INSERT INTO `status` VALUES ('Used', 'Spare', 'Empty', 'Empty', 'Tank Damage', 'Used', 'Empty', 'Empty', 'Empty', 'Tank Damage', 'Empty', 'Used', '', '2011-05-10 12:33:39', '10.05.11');
INSERT INTO `status` VALUES ('Used', 'Spare', 'Empty', 'Empty', 'Tank Damage', 'Used', 'Empty', 'Empty', 'Empty', 'Tank Damage', 'Empty', 'Used', '', '2011-05-10 12:33:41', '10.05.11');
INSERT INTO `status` VALUES ('Used', 'Spare', 'Empty', 'Empty', 'Tank Damage', 'Used', 'Empty', 'Empty', 'Empty', 'Tank Damage', 'Empty', 'Used', '', '2011-05-10 12:33:43', '10.05.11');
INSERT INTO `status` VALUES ('Used', 'Spare', 'Empty', 'Empty', 'Tank Damage', 'Used', 'Empty', 'Empty', 'Empty', 'Tank Damage', 'Empty', 'Used', '', '2011-05-10 12:33:48', '10.05.11');
INSERT INTO `status` VALUES ('Used', 'Spare', 'Empty', 'Empty', 'Tank Damage', 'Used', 'Empty', 'Empty', 'Empty', 'Tank Damage', 'Empty', 'Used', '', '2011-05-10 12:33:50', '10.05.11');
INSERT INTO `status` VALUES ('Used', 'Spare', 'Empty', 'Empty', 'Tank Damage', 'Used', 'Empty', 'Empty', 'Empty', 'Tank Damage', 'Empty', 'Used', '', '2011-05-10 12:33:52', '10.05.11');
INSERT INTO `status` VALUES ('Used', 'Spare', 'Empty', 'Empty', 'Tank Damage', 'Used', 'Empty', 'Empty', 'Empty', 'Tank Damage', 'Empty', 'Used', '', '2011-05-10 12:33:54', '10.05.11');
ช่วยแก้ให้หน่อยน้า
Tag : PHP, CakePHP
|
|
|
|
|
|
Date :
2011-05-10 17:56:06 |
By :
sambeem001 |
View :
678 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองดูแบบนี้ก่อนครับง่าย ๆ แต่ไม่รู้ตรงความต้องการรึเปล่า
Code (PHP)
<!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=windows-874" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- TemplateEndEditable -->
<!-- TemplateBeginEditable name="head" -->
<!-- TemplateEndEditable -->
<style>
body{
font-size:12px;
margin:0px;
padding:0px;
}
</style>
</head>
<body>
<?php
mysql_connect("localhost", "root", "123456") or die(mysql_error());
mysql_select_db(testmember) or die(mysql_error());
$yesterday= "06.05.11";
$today="10.05.11";
$data = "SELECT * FROM status WHERE datetime >='$yesterday' AND datetime<='$today'";
$rss=mysql_query($data);
//print $data;
print "<table width='100' border='1' cellpadding='0' cellspacing='0' align=center>";
print "<tr>";
print "<td width='90' height='26' bgcolor='#99FF99' ><div align='center'><strong>Nitrogen Tank No.</strong></div></td>";
print "<td width='90' height='26' bgcolor='#99FF99' ><div align='center'><strong>Nitrogen Tank No.</strong></div></td>";
print "<td width='90' height='26' bgcolor='#99FF99' ><div align='center'><strong>Nitrogen Tank No.</strong></div></td>";
print "<td width='90' height='26' bgcolor='#99FF99' ><div align='center'><strong>Nitrogen Tank No.</strong></div></td>";
print "<td width='90' height='26' bgcolor='#99FF99' ><div align='center'><strong>Nitrogen Tank No.</strong></div></td>";
print "<td width='90' height='26' bgcolor='#99FF99' ><div align='center'><strong>Nitrogen Tank No.</strong></div></td>";
print "<td width='90' height='26' bgcolor='#99FF99' ><div align='center'><strong>Nitrogen Tank No.</strong></div></td>";
print "<td width='90' height='26' bgcolor='#99FF99' ><div align='center'><strong>Nitrogen Tank No.</strong></div></td>";
print "<td width='90' height='26' bgcolor='#99FF99' ><div align='center'><strong>Nitrogen Tank No.</strong></div></td>";
print "<td width='90' height='26' bgcolor='#99FF99' ><div align='center'><strong>Nitrogen Tank No.</strong></div></td>";
print "<td width='90' height='26' bgcolor='#99FF99' ><div align='center'><strong>Nitrogen Tank No.</strong></div></td>";
print "<td width='90' height='26' bgcolor='#99FF99' ><div align='center'><strong>Nitrogen Tank No.</strong></div></td>";
print "<td width='90' height='26' bgcolor='#99FF99' ><div align='center'><strong>Nitrogen Tank No.</strong></div></td>";
print "<td width='90' height='26' bgcolor='#99FF99' ><div align='center'><strong>Nitrogen Tank No.</strong></div></td>";
print "<td width='90' height='26' bgcolor='#99FF99' ><div align='center'><strong>Nitrogen Tank No.</strong></div></td>";
print "</tr>";
while($info = mysql_fetch_array( $rss ))
{
print "<tr>";
print "<td height='33' bgcolor='#99FF99'><div align='center'><strong>".$info[no1]."</strong></div></td>";
print "<td height='33' bgcolor='#99FF99'><div align='center'><strong>".$info[no2]."</strong></div></td>";
print "<td height='33' bgcolor='#99FF99'><div align='center'><strong>".$info[no3]."</strong></div></td>";
print "<td height='33' bgcolor='#99FF99'><div align='center'><strong>".$info[no4]."</strong></div></td>";
print "<td height='33' bgcolor='#99FF99'><div align='center'><strong>".$info[no5]."</strong></div></td>";
print "<td height='33' bgcolor='#99FF99'><div align='center'><strong>".$info[no6]."</strong></div></td>";
print "<td height='33' bgcolor='#99FF99'><div align='center'><strong>".$info[no7]."</strong></div></td>";
print "<td height='33' bgcolor='#99FF99'><div align='center'><strong>".$info[no8]."</strong></div></td>";
print "<td height='33' bgcolor='#99FF99'><div align='center'><strong>".$info[no9]."</strong></div></td>";
print "<td height='33' bgcolor='#99FF99'><div align='center'><strong>".$info[no10]."</strong></div></td>";
print "<td height='33' bgcolor='#99FF99'><div align='center'><strong>".$info[no11]."</strong></div></td>";
print "<td height='33' bgcolor='#99FF99'><div align='center'><strong>".$info[no12]."</strong></div></td>";
print "<td height='33' bgcolor='#99FF99'><div align='center'><strong>".$info[no13]."</strong></div></td>";
print "<td height='33' bgcolor='#99FF99'><div align='center'><strong>".$info[timestamp]."</strong></div></td>";
print "<td height='33' bgcolor='#99FF99'><div align='center'><strong>".$info[datetime]."</strong></div></td>";
print "</tr>";
}
print "</table>";
print "</body>";
?>
</html>
|
|
|
|
|
Date :
2011-05-10 21:59:44 |
By :
มือใหม่หัดเขียนโปรแกรม |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|