|
|
|
อยากได้โค้ดแบ่งคอลัมน์ครับช่วยหน่อย คือผมอยากได้โค้ดแบ่งคอลัมน์ของ php ครับ อยากจะแบ่งออกเป็น 3 คอลัมน์ 2 แถว ท่านผู้รู้กรุณาด้วยนะครับผมจะทำโปรเจคจบ |
|
|
|
|
|
|
|
<? //======================= Powered Source Code ============
// Source Code Develop By : Wongvian Wongkaso
// tel : 08-7953-0412
// มหาวิทยาลัยราชภัฏสกลนคร
// โปรแกรมวิชาเทคโนโลยีสารสนเทค 461794126
?>
<? include("function.php");?>
<style type="text/css">
<!--
.style1 {font-weight: bold}
.style2 {
font-size: larger;
font-weight: bold;
}
.style3 {color: #FF0000}
.style7 {color: #0000FF}
.style8 {color: #009933}
.style9 {color: #000000}
-->
</style>
<hr align="center">
<div align="center" class="style1">
<div align="center"><strong>ข้อมูลห้องพัก</strong> วันที่<? echo $x_order_date = date("d "). month(date(" m ")). (date(" Y")+543); ?> เวลา
<? echo date("H:i:s"); ?>
ผู้ใช้งานระบบ คุณ
<?=$member_fname.$member_lname?>
</div>
</div>
<hr align="center"/ >
<div align="center">
<table>
<?
$sql ="SELECT DISTINCT
order_master
.order_id,
`room`.`room_no`,
`order_master`.`order_id`,
`room`.`status`,
`order_master`.`status`
FROM
`room`
Left Join `order_master` ON `room`.`room_no` = `order_master`.`room_no` AND `order_master`.`status` = `room`.`status`
";
$q = mysql_query($sql);
$count=0;
$i=0;
while($data = mysql_fetch_array($q))
{
$i++;
if($count==0)
{
?>
<?
if($i==16 || $i==32 || $i==48 || $i==64){
echo '<tr >';
}
?>
<td valign="top">
<? if($data["3"]=="VC"){?>
<a href="desition_way.php?val=check_in&room_no=<?=$data["room_no"] ;?>"><img src="images/Home_vc.gif" alt="<? echo $data["room_no"]; ?>" width="32" height="34" border="0" /></a><br />
<strong> <? echo $data["room_no"]; ?></strong><hr/ >
<? }else{ ?>
<a href="desition_way.php?val=check_out&order_id=<?=$data["order_id"];?>"><img src="images/Home_oc.gif" alt="<? echo $data["room_no"]; ?>" width="32" height="34" border="0" /></a><br />
<strong> <? echo $data["room_no"]; ?></strong><hr/ > <? }?>
<span class="style1"><? echo $data["detail"]; ?></span> </td>
</td >
<?
$count++;
}
else
{
?>
<td valign="top">
<? if($data["3"]=="VC"){?>
<a href="desition_way.php?val=check_in&room_no=<?=$data["room_no"] ;?>"><img src="images/Home_vc.gif" alt="<? echo $data["room_no"]; ?>" width="32" height="34" border="0" /></a><br />
<strong> <? echo $data["room_no"]; ?></strong><hr/ >
<? }else{ ?>
<a href="desition_way.php?val=check_out&order_id=<?=$data["order_id"] ;?>"><img src="images/Home_oc.gif" alt="<? echo $data["room_no"]; ?>" width="32" height="34" border="0" /></a><br />
<strong> <? echo $data["room_no"]; ?></strong> <hr/ > <? }?>
<span class="style1"><? echo $data["detail"]; ?></span> </td>
<td></td>
<?
if($i==16 || $i==32 || $i==48 || $i==64){
echo '</tr>';
}
?>
<?
$count=0;
}
?>
<?
}
?>
</table>
</div>
<hr align="center"/ >
<div align="center"><br />
<span class="style2">
<?
$sql_count = "select count(if(status='VC',1,null)) as vc,count(if(status='OC',1,null)) as oc from room";
$re = mysql_query($sql_count,$conn);
$dbarr =mysql_fetch_array($re);
?>
<span class="style9">ห้องว่าง</span> <span class="style8">
<?=$vc1=$dbarr['vc']; ?>
</span>
<span class="style9">ห้อง
จำนวนห้องที่มีแขกเข้าพัก</span> </span><span class="style3"><span class="style2">
<?=$vc2=$dbarr['oc'];?>
</span></span><span class="style2">
<span class="style9">ห้อง
ห้องพักทั้งหมด</span><span class="style7">
<? echo $room = ($dbarr['vc'])+($dbarr['oc']); ?>
</span> <span class="style9">ห้อง</span></span><br />
</div>
|
|
|
|
|
Date :
30 พ.ย. 2549 13:42:42 |
By :
aor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
/*** By Weerachai Nukitram ***/
/*** http://www.ThaiCreate.Com ***/
?>
<html>
<head>
<title>ThaiCreate.Com Multiple Column</title>
</head>
<body>
<div align="center">
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM gallery ORDER BY GalleryID ASC ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
echo"<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\"><tr>";
$intRows = 0;
while($objResult = mysql_fetch_array($objQuery))
{
$intRows++;
echo "<td>";
?>
<table width="91" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="center"><a href="gallery/<?=$objResult["Picture"];?>" target="_blank"><img src="gallery/<?=$objResult["Thumbnails"];?>" width="70" height="53" border="0"></a></div></td>
</tr>
<tr>
<td><div align="center"><?=$objResult["GalleryName"];?></div></td>
</tr>
</table>
<?
echo"</td>";
if(($intRows)%2==0)
{
echo"</tr>";
}
else
{
echo "<td>";
}
}
echo"</tr></table>";
?>
<?
mysql_close($objConnect);
?>
</div>
</body>
</html>
Ref : Multiple Column แสดงข้อมูลจากฐานข้อมูลด้วยการแบ่งออกเป็นหลาย Column
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<body>
<?
$objConnect = mysql_connect("localhost","root","root") or die(mysql_error());
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM gallery";
$objQuery = mysql_query($strSQL);
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 4; // Per Page
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
$strSQL .=" order by GalleryID ASC LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
echo"<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\"><tr>";
$intRows = 0;
while($objResult = mysql_fetch_array($objQuery))
{
echo "<td>";
$intRows++;
?>
<center>
<img src="shotdev/<?=$objResult["Picture"];?>"><br>
<?=$objResult["GalleryName"];?>
<br>
</center>
<?
echo"</td>";
if(($intRows)%2==0)
{
echo"</tr>";
}
}
echo"</tr></table>";
?>
<br>
Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page :
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> ";
}
?>
</body>
</html>
<?
mysql_close($objConnect);
?>
SQL
CREATE TABLE `gallery` (
`GalleryID` int(11) NOT NULL auto_increment,
`GalleryName` varchar(100) NOT NULL,
`Picture` varchar(100) NOT NULL,
PRIMARY KEY (`GalleryID`)
) ENGINE=MyISAM ;
INSERT INTO `gallery` VALUES (1, 'Picture 1', 'img1.jpg');
INSERT INTO `gallery` VALUES (2, 'Picture 2', 'img2.jpg');
INSERT INTO `gallery` VALUES (3, 'Picture 3', 'img3.jpg');
INSERT INTO `gallery` VALUES (4, 'Picture 4', 'img4.jpg');
INSERT INTO `gallery` VALUES (5, 'Picture 5', 'img5.jpg');
INSERT INTO `gallery` VALUES (6, 'Picture 6', 'img6.jpg');
INSERT INTO `gallery` VALUES (7, 'Picture 7', 'img7.jpg');
INSERT INTO `gallery` VALUES (8, 'Picture 8', 'img8.jpg');
|
|
|
|
|
Date :
2009-11-13 06:55:43 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|