|
|
|
ต้องการสลับสีตามข้อมูลประเภท คือว่าต้องการแสดงข้อมูลสินค้าตามประเภทแล้วให้มันสลับสีตามประเภทครับ |
|
|
|
|
|
|
|
Code (PHP)
<?php
$colorArray = array(1 => '#FF99CC',2 => '#FFCC99',3 => '#FFFF99',4 => '#CCFFCC',5 => '#CCFFFF',6 => '#CC99FF', 7 => '#C0C0C0');
$color = $colorArray[$row['typeid']];
echo $color;
?>
ในที่นี่ typeid ต้องมีค่า 1-7 อยากได้สีอะไรเพิ่มเติม ก็ได้ตามใจชอบ อิอิ
|
|
|
|
|
Date :
2009-05-28 18:22:41 |
By :
danya |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
</head>
<body>
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM customer";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">CustomerID </div></th>
<th width="98"> <div align="center">Name </div></th>
<th width="198"> <div align="center">Email </div></th>
<th width="97"> <div align="center">CountryCode </div></th>
<th width="59"> <div align="center">Budget </div></th>
<th width="71"> <div align="center">Used </div></th>
</tr>
<?
$i=0;
while($objResult = mysql_fetch_array($objQuery))
{
$i++;
if($i%2==0)
{
$bg = "#CCCCCC";
}
else
{
$bg = "#FFFFFF";
}
?>
<tr bgcolor="<?=$bg;?>">
<td><div align="center"><?=$objResult["CustomerID"];?></div></td>
<td><?=$objResult["Name"];?></td>
<td><?=$objResult["Email"];?></td>
<td><div align="center"><?=$objResult["CountryCode"];?></div></td>
<td align="right"><?=$objResult["Budget"];?></td>
<td align="right"><?=$objResult["Used"];?></td>
</tr>
<?
}
?>
</table>
<?
mysql_close($objConnect);
?>
</body>
</html>
|
|
|
|
|
Date :
2009-05-28 18:29:19 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
พี่ MR.WIN
อยากให้สลับสีอย่างรูปภาพนี้อะสลับตาม CountryCode
|
|
|
|
|
Date :
2009-05-29 23:20:50 |
By :
nittaya924 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
[font=Verdana]<html>
<head>
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
</head>
<body>
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM customer";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">CustomerID </div></th>
<th width="98"> <div align="center">Name </div></th>
<th width="198"> <div align="center">Email </div></th>
<th width="97"> <div align="center">CountryCode </div></th>
<th width="59"> <div align="center">Budget </div></th>
<th width="71"> <div align="center">Used </div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
$bg = ($oldcode == $objResult["CountryCode"])? "#CCC" : "#FFF";
?>
<tr bgcolor="<?=$bg;?>">
<td><div align="center"><?=$objResult["CustomerID"];?></div></td>
<td><?=$objResult["Name"];?></td>
<td><?=$objResult["Email"];?></td>
<td><div align="center"><?=$objResult["CountryCode"];?></div></td>
<td align="right"><?=$objResult["Budget"];?></td>
<td align="right"><?=$objResult["Used"];?></td>
</tr>
<?
$oldcode = $objResult["CountryCode"];
}
?>
</table>
<?
mysql_close($objConnect);
?>
</body>
</html>
[/font]
?>
|
|
|
|
|
Date :
2009-05-29 23:31:48 |
By :
plakrim |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ยังไม่ได้เลยครับข้อมูลผิดอยู่ครับช่วยแนะนำอีกนิด พี่PlaKriM
ข้อมูลในฐานข้อมูลนะครับที่ใช้ทดสอบครับ
INSERT INTO `customer` VALUES ('C001', 'Win Weerachai', '[email protected]', 'TH', 1000000, 600000);
INSERT INTO `customer` VALUES ('C002', 'John Smith', '[email protected]', 'EN', 2000000, 800000);
INSERT INTO `customer` VALUES ('C003', 'Jame Born', '[email protected]', 'US', 3000000, 600000);
INSERT INTO `customer` VALUES ('C004', 'Chalee Angel', '[email protected]', 'US', 4000000, 100000);
INSERT INTO `customer` VALUES ('C005', 'Win Weerachai', '[email protected]', 'US', 1000000, 600000);
INSERT INTO `customer` VALUES ('C006', 'John Smith', '[email protected]', 'TH', 2000000, 800000);
INSERT INTO `customer` VALUES ('C007', 'Win Weerachai', '[email protected]', 'TH', 1000000, 600000);
INSERT INTO `customer` VALUES ('C008', 'John Smith', '[email protected]', 'UK', 2000000, 800000);
INSERT INTO `customer` VALUES ('C009', 'Win Weerachai', '[email protected]', 'JP', 1000000, 600000);
INSERT INTO `customer` VALUES ('C010', 'John Smith', '[email protected]', 'JP', 2000000, 800000);
|
|
|
|
|
Date :
2009-05-30 00:20:45 |
By :
nittaya924 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ให้มาแต่ insert แล้ว create ละ
|
|
|
|
|
Date :
2009-05-30 00:25:51 |
By :
plakrim |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอโทษครับผมจะเอาไปประยุกต์กับโปรเจ็คผมเขียนไม่ได้ซักทีครับ ขอบคุณครับ
CREATE TABLE `customer` (
`CustomerID` varchar(4) NOT NULL,
`Name` varchar(50) NOT NULL,
`Email` varchar(50) NOT NULL,
`CountryCode` varchar(2) NOT NULL,
`Budget` double NOT NULL,
`Used` double NOT NULL,
PRIMARY KEY (`CustomerID`)
) ENGINE=MyISAM DEFAULT CHARSET=tis620;
INSERT INTO `customer` VALUES ('C001', 'Win Weerachai', '[email protected]', 'TH', 1000000, 600000);
INSERT INTO `customer` VALUES ('C002', 'John Smith', '[email protected]', 'EN', 2000000, 800000);
INSERT INTO `customer` VALUES ('C003', 'Jame Born', '[email protected]', 'US', 3000000, 600000);
INSERT INTO `customer` VALUES ('C004', 'Chalee Angel', '[email protected]', 'US', 4000000, 100000);
INSERT INTO `customer` VALUES ('C005', 'Win Weerachai', '[email protected]', 'US', 1000000, 600000);
INSERT INTO `customer` VALUES ('C006', 'John Smith', '[email protected]', 'TH', 2000000, 800000);
INSERT INTO `customer` VALUES ('C007', 'Win Weerachai', '[email protected]', 'TH', 1000000, 600000);
INSERT INTO `customer` VALUES ('C008', 'John Smith', '[email protected]', 'UK', 2000000, 800000);
INSERT INTO `customer` VALUES ('C009', 'Win Weerachai', '[email protected]', 'JP', 1000000, 600000);
INSERT INTO `customer` VALUES ('C010', 'John Smith', '[email protected]', 'JP', 2000000, 800000);
INSERT INTO `customer` VALUES ('C011', 'John Smith', '[email protected]', 'JP', 2000000, 800000);
|
|
|
|
|
Date :
2009-05-30 00:30:32 |
By :
nittaya924 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
<html>
<head>
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
</head>
<body>
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM customer";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">CustomerID </div></th>
<th width="98"> <div align="center">Name </div></th>
<th width="198"> <div align="center">Email </div></th>
<th width="97"> <div align="center">CountryCode </div></th>
<th width="59"> <div align="center">Budget </div></th>
<th width="71"> <div align="center">Used </div></th>
</tr>
<?
$i=0;
while($objResult = mysql_fetch_array($objQuery))
{
if($oldcode != $objResult["CountryCode"]) $i++;
$bg = ($i%2==1)? "#CCCCCC" : "#FFFFFF";
?>
<tr bgcolor="<?=$bg;?>">
<td><div align="center"><?=$objResult["CustomerID"];?></div></td>
<td><?=$objResult["Name"];?></td>
<td><?=$objResult["Email"];?></td>
<td><div align="center"><?=$objResult["CountryCode"];?></div></td>
<td align="right"><?=$objResult["Budget"];?></td>
<td align="right"><?=$objResult["Used"];?></td>
</tr>
<?
$oldcode = $objResult["CountryCode"];
}
?>
</table>
<?
mysql_close($objConnect);
?>
</body>
</html>
?>
|
|
|
|
|
Date :
2009-05-30 00:42:48 |
By :
plakrim |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณมากครับโปรเจ็คก้าวไปอีกนิดหละครับ
|
|
|
|
|
Date :
2009-05-30 00:49:46 |
By :
nittaya924 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ดีครับ ก้าวต่อไป ฮานามิ
|
|
|
|
|
Date :
2009-05-30 00:50:36 |
By :
plakrim |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|