|
 |
|
ถ้าเราสร้างตารางโดยใช้ array เราสามารถกำหนดสีของตารางไม่ให้เหมือนกันได้มั้ยค่ะ |
|
 |
|
|
 |
 |
|
ได้ครับ
วิธีการ
เช็ครอบของลูปว่าเป็นคู่หรือคี่ ถ้าคู่ก็ใส่สีนึง ถ้าคี่ก็ใส่อีกสีนึงแค่นั้นเองครับ
$i%2==0
|
 |
 |
 |
 |
Date :
2009-07-13 15:16:48 |
By :
lozomac |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ยังไงอ่าค่ะแล้วจาใส่ตรงส่วนไหน
|
 |
 |
 |
 |
Date :
2009-07-13 15:21:19 |
By :
gummezaka |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตารางประมาณนี้ค่ะ

|
 |
 |
 |
 |
Date :
2009-07-13 15:27:28 |
By :
gummezaka |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขุดๆๆๆ
|
 |
 |
 |
 |
Date :
2009-07-13 17:54:47 |
By :
gummezaka |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$bgcolor = "#000000";
if($i%2==0)
{
$bgcolor = "#ffffff";
}
ใส่ในลูป ส่วนใส่สีตรงไหน คงไม่ต้องให้บอก

|
 |
 |
 |
 |
Date :
2009-07-13 18:58:12 |
By :
lozomac |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมก็ไม่รู้ว่าจะตอบตรงหรือเปล่านะคับ
Code (PHP)
<?php
$sql="selest * from test Orderby id";
$result=mysql_query($sql);
while($row=mysql_fetch_array($result){
if($tb==#โค้ดสีตามต้องการ){
$tb="#โค้ดสีตามต้องการ";
} else {
$tb="#โค้ดสีตามต้องการ";
}
//ประกาศใช้คำสั่ง
?>
//คำสั่ง html
<tr bgcolor="<?=$tb;?>">
ถ้าไม่ต้องตามที่ต้องการต้องขออภัยด้วยนะคับ
|
 |
 |
 |
 |
Date :
2009-07-13 19:03:51 |
By :
somparn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จะสลับสีเฉพาะ head ของ table หรือเปล่า ลองเอาโค๊ดมาดูหน่อยซิ
|
 |
 |
 |
 |
Date :
2009-07-13 21:10:57 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่ายแล้วค่ะสลับเฉพาะหัวเทเบิ้ลค่ะ โค๊ดเปงแบบนี้อ่ะค่ะ
<?
include "function.php";
include "connect.php";
for ($i=1; $i<=count($statustype); $i++) {
echo "
<center><table width='70%' border='0'>
<tr bgcolor='#0099FF'>
<td width='2%'><center><b><font color='#FFFFFF'font size='2' face='MS Sans Serif'>ลำดับ</font></b></center></td>
<td width='3%'><center><b><font color='#FFFFFF'font size='2' face='MS Sans Serif'>วันที่</font></b></center></td>
<td width='2%'><center><b><font color='#FFFFFF'font size='2' face='MS Sans Serif'>เวลา</font></b></center></td>
<td width='4%'><center><b><font color='#FFFFFF'font size='2' face='MS Sans Serif'>เลขที่บิล</font></b></center></td>
<td width='2%'><center><b><font color='#FFFFFF'font size='2' face='MS Sans Serif'>จำนวน</font></b></center></td>
<td width='5%'><center><b><font color='#FFFFFF'font size='2' face='MS Sans Serif'>ชื่อผู้เปิดบิลขาย</font></b></center></td>
<td width='5%'><center><b><font color='#FFFFFF'font size='2' face='MS Sans Serif'>ชื่อผู้หยิบ</font></b></center></td>
<td width='5%'><center><b><font color='#FFFFFF'font size='2' face='MS Sans Serif'>สถานะบิล</font></b></center></td>
</tr>";
$no=1;
$sql="select * from alai where status='$i' ";
$result=mysql_db_query($dbname,$sql);
$total=mysql_num_rows($result);
$sql="select * from alai where status='$i' order by date_today desc ";
$result=mysql_db_query($dbname,$sql);
while($r=mysql_fetch_array($result)) {
$id_status=$r[id_status];
$po_status=$r[po_status];
$count_status=$r[count_status];
$fname_status=$r[fname_status];
$name_status=$r[name_status];
$status=$r[status];
$date_today=displaydate($r[date_today]);
$time_today=$r[time_today];
echo "
<br>
<tr bgcolor='#FFFFFF'>
<td width='2%' ><center><font size='2' face='MS Sane Serif'>$no</font></center></td>
<td width='3%' ><center><font size='2' face='MS Sane Serif'>$date_today</font></center></td>
<td width='2%' ><center><font size='2' face='MS Sane Serif'>$time_today</font></center></td>
<td width='4%' ><center><font size='2' face='MS Sane Serif'>$po_status</font></center></td>
<td width='2%' ><center><font size='2' face='MS Sane Serif'>$count_status</font></center></td>
<td width='5%' ><center><font size='2' face='MS Sane Serif'> $fnametype[$fname_status]</font></center></td>
<td width='5%' ><center><font size='2' face='MS Sane Serif'> $nametype[$name_status]</font></center></td>
<td width='5%' ><center><font size='2' face='MS Sane Serif'> $statustype[$status]</font></center></td>
</tr>";
$no++;
}
}
?>
|
 |
 |
 |
 |
Date :
2009-07-14 08:29:25 |
By :
gummezaka |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
for ($i=1; $i<=count($statustype); $i++) {
$bgcolor = ($i%2==0)? "#FF0000" : "#0099FF";
echo "
<center><table width='70%' border='0'>
<tr bgcolor='" . $bgcolor . "'>
|
 |
 |
 |
 |
Date :
2009-07-14 10:55:47 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อันนี้มันได้ 2 สีนี่ค่ะ ถ้าเราต้องการเพิ่มเป็น 3-4-5 อารายทำนองเนี้ยเราจะแก้ตรงไหนเหร๋อค่ะ
|
 |
 |
 |
 |
Date :
2009-07-14 12:13:04 |
By :
gummezaka |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าแบบนั้นคงต้องเก็บสีไว้ใน array ครับผม
|
 |
 |
 |
 |
Date :
2009-07-14 12:15:55 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ยังไงอ่าค่ะ
|
 |
 |
 |
 |
Date :
2009-07-14 12:20:32 |
By :
gummezaka |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$bgcolor = array("#FF0000","#CCCCC","#EEEEE","#0099FF");
for ($i=1; $i<=count($statustype); $i++) {
echo "
<center><table width='70%' border='0'>
<tr bgcolor='" . $bgcolor[$i] . "'>
แบบนี้ครับ แต่ต้องใส่ไว้เยอะๆ นะ
|
 |
 |
 |
 |
Date :
2009-07-14 13:26:17 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
น่าจะเป็นลักษณะกำหนด สีไว้ก่อน เช่น
Code (PHP)
<?php
// ลูปแรกที่แสดงข้อมูลหัวข้อที่แบ่งประเภท
$i=0;
while ...............
{ อะไรก็ว่าไป แล้วไปใส่สีไว้ใน อะเรย์ เช่น
$bg=array('#F0F0F0','#99F0F0','#50F0F0','#F33330');
// แล้วใน ตารางใส่อันนี้เข้าไป
<table bgcolor="<?echo $bg[$i];?>
// ลูป2ที่แสดงข้อมูล
$a=0;
while ...............
{ อะไรก็ว่าไป ..........
$a++;
}
$i++; }
?>
|
 |
 |
 |
 |
Date :
2009-07-14 13:43:25 |
By :
tingtongkub |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จะได้ประมาณรี้ครับ

|
 |
 |
 |
 |
Date :
2009-07-14 13:50:06 |
By :
tingtongkub |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ค่ะ ขอบคุณค่ะ ตอนนี้ทำสีได้แว้ววค่ะ
|
 |
 |
 |
 |
Date :
2009-07-14 14:16:26 |
By :
gummezaka |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|