|
|
|
ขอความช่วยเหลือครับ ถ้าต้องการเพิ่มเติมให้มี highlight เพิ่มโดยอ่านค่าจาก field level2 = 3 ต้องเขียนcode php และ css เพิ่มอย่างไรครับ |
|
|
|
|
|
|
|
ต้องขออภัยที่ต้อง ขอความช่วยเหลือ ในเรื่องเดิมมาอักครั้งนะครับ เพราะยังแก้ปัญหานี้ไม่ได้ครับ
Code (PHP)
็highlightBylevel.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>
<title>Untitled Document</title>
<style type="text/css">
table#gridview {
clear:both;
}
table#gridview td {
padding:3px 0px;
}
table#gridview tr.head {
background:#B18904;
font-family:Arial, Helvetica, sans-serif;
text-align:center;
}
table#gridview tr.head td {
padding:3px 0px;
}
.bb2 {
font-size: 14px;
}
text-indent:0.5in;
#gridviewsss {
color: #FFF;
}
body {
background-color: #D3D3D3;
}
body,td,th {
color: #909090;
}
thead > tr{background:#A2C4AA;}
th, td{font-family:font-family:Arial, Helvetica, sans-serif}
thead th{color:#fff;font-size:14px;}
tr{height:44px;}
tbody > tr:nth-child(even) {background: #f3f3f3}
tbody > tr:nth-child(odd) {background: #fff}
tr.tr2 {background:#FFB7B7 !important}
tbody > tr:hover, tr.tr2:hover, tr.tr3:hover{background:#fff5e6 !important}
tbody td{font-size:13px;color:#000}
tbody td > div{text-align:center}
.text-center{text-align:center}
.hide{display: none;visibility: hidden;}
</style>
<body>
<?php
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("ots_data");
$strSQL = "SELECT * FROM customer";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$strSQL .=" order by id desc ";
$objQuery = mysql_query($strSQL);
?>
<table class="display" width="800" height="135" border="0" align="center" cellpadding="1" cellspacing="1" id="gridview">
<thead> <tr>
<th width="35"> ID </th>
<th width="134" >Reservation Date</th>
<th width="212"> Guest Name</th>
<th width="161"> Destination</th>
<th width="79"> Amount</th>
<th width="41">Level</th>
<th width="41">Level2</th>
<th width="64">Remark</th>
<th width="49"> </th>
</tr>
</thead>
<?php
while($objResult = mysql_fetch_array($objQuery))
{
$id = $objResult["id"];
$remark = $objResult["remark"];
$edit_class = (trim($remark) == '') ? '' : ' hide';
$tr_class = '';
if ($objResult['level'] == '2')
{
$tr_class = ' class="tr'.$objResult['level'].'"';
}
echo '<tr'.$tr_class.'>';
?>
<td height="42"><div><?php echo $id;?></div></td>
<td><?php echo $objResult["reservation_date"];?></td>
<td><?php echo $objResult["destination"];?></td>
<td><?php echo $objResult["guest_name"];?></td>
<td><?php echo $objResult["amount"];?></td>
<td><?php echo $objResult["level"];?></td>
<td><?php echo $objResult["level2"];?></td>
<td><?php echo $remark;?></td>
<td bgcolor="#999999">
<div class="text-center<?php echo $edit_class;?>">
<a href="edit.php?edit_id=<?=$objResult[id]?>">EDIT</a></div></td>
</tr>
<?php
}
?>
</table>
</body>
</html>
ขอบพระคุณมากครับ
Tag : PHP
|
ประวัติการแก้ไข 2016-06-14 08:13:28
|
|
|
|
|
Date :
2016-06-14 08:12:13 |
By :
panya@ots |
View :
768 |
Reply :
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.lv3_2 {background: #???} กำหนด หลัง tbody > tr:nth-child(odd)
081.echo '<tr'.$tr_class.($level3==2? ' lv3_2' : '').'>';
|
|
|
|
|
Date :
2016-06-14 08:53:25 |
By :
Chaidhanan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แก้ไว้ยังไงครับ เอาที่แก้แล้วมาดู
|
|
|
|
|
Date :
2016-06-14 15:27:56 |
By :
Chaidhanan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอบความคิดเห็นที่ : 3 เขียนโดย : Chaidhanan เมื่อวันที่ 2016-06-14 15:27:56
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>
<title>Untitled Document</title>
<style type="text/css">
table#gridview {
clear:both;
}
table#gridview td {
padding:3px 0px;
}
table#gridview tr.head {
background:#B18904;
font-family:Arial, Helvetica, sans-serif;
text-align:center;
}
table#gridview tr.head td {
padding:3px 0px;
}
.bb2 {
font-size: 14px;
}
text-indent:0.5in;
#gridviewsss {
color: #FFF;
}
body {
background-color: #D3D3D3;
}
body,td,th {
color: #909090;
}
thead > tr{background:#A2C4AA;}
th, td{font-family:font-family:Arial, Helvetica, sans-serif}
thead th{color:#fff;font-size:14px;}
tr{height:44px;}
tbody > tr:nth-child(even) {background: #f3f3f3}.lv3_2 {background:#DAF7A6 }
tbody > tr:nth-child(odd) {background: #fff}
tr.tr2 {background:#FFB7B7 !important}
tbody > tr:hover, tr.tr2:hover, tr.tr3:hover{background:#fff5e6 !important}
tbody td{font-size:13px;color:#000}
tbody td > div{text-align:center}
.text-center{text-align:center}
.hide{display: none;visibility: hidden;}
</style>
<body>
<?php
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("ots_data");
$strSQL = "SELECT * FROM customer";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$strSQL .=" order by id desc ";
$objQuery = mysql_query($strSQL);
?>
<table class="display" width="800" height="135" border="0" align="center" cellpadding="1" cellspacing="1" id="gridview">
<thead> <tr>
<th width="35"> ID </th>
<th width="134" >Reservation Date</th>
<th width="212"> Guest Name</th>
<th width="161"> Destination</th>
<th width="79"> Amount</th>
<th width="41">Level</th>
<th width="64">Level2</th>
<th width="64">Remark</th>
<th width="49"> </th>
</tr>
</thead>
<?php
while($objResult = mysql_fetch_array($objQuery))
{
$id = $objResult["id"];
$remark = $objResult["remark"];
$edit_class = (trim($remark) == '') ? '' : ' hide';
$tr_class = '';
if ($objResult['level'] == '2' OR $objResult['level'] == 3)
{
$tr_class = ' class="tr'.$objResult['level'].'"';
}
echo '<tr'.$tr_class.($level3==2? ' lv3_2' : '').'>';
?>
<td height="42"><div><?php echo $id;?></div></td>
<td><?php echo $objResult["reservation_date"];?></td>
<td><?php echo $objResult["destination"];?></td>
<td><?php echo $objResult["guest_name"];?></td>
<td><?php echo $objResult["amount"];?></td>
<td><?php echo $objResult["level"];?></td>
<td><?php echo $objResult["level2"];?></td>
<td><?php echo $remark;?></td>
<td bgcolor="#999999">
<div class="text-center<?php echo $edit_class;?>">
<a href="edit.php?edit_id=<?=$objResult[id]?>">EDIT</a></div></td>
</tr>
<?php
}
?>
</table>
</body>
</html>
|
ประวัติการแก้ไข 2016-06-14 16:47:15
|
|
|
|
Date :
2016-06-14 16:45:05 |
By :
panya@ots |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
็highlightBylevel.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>
<title>Untitled Document</title>
<style type="text/css">
table#gridview {
clear:both;
}
table#gridview td {
padding:3px 0px;
}
table#gridview tr.head {
background:#B18904;
font-family:Arial, Helvetica, sans-serif;
text-align:center;
}
table#gridview tr.head td {
padding:3px 0px;
}
.bb2 {
font-size: 14px;
}
text-indent:0.5in;
#gridviewsss {
color: #FFF;
}
body {
background-color: #D3D3D3;
}
body,td,th {
color: #909090;
}
thead > tr{background:#A2C4AA;}
th, td{font-family:font-family:Arial, Helvetica, sans-serif}
thead th{color:#fff;font-size:14px;}
tr{height:44px;}
tbody > tr:nth-child(even) {background: #f3f3f3}
tbody > tr:nth-child(odd) {background: #fff}
tr.tr2 {background:#FFB7B7 !important}
tbody > tr:hover, tr.tr2:hover, tr.tr3:hover{background:#fff5e6 !important}
tbody td{font-size:13px;color:#000}
tbody td > div{text-align:center}
.text-center{text-align:center}
.hide{display: none;visibility: hidden;}
</style>
<body>
<?php
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("ots_data");
$strSQL = "SELECT * FROM customer";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$strSQL .=" order by id desc ";
$objQuery = mysql_query($strSQL);
?>
<table class="display" width="800" height="135" border="0" align="center" cellpadding="1" cellspacing="1" id="gridview">
<thead> <tr>
<th width="35"> ID </th>
<th width="134" >Reservation Date</th>
<th width="212"> Guest Name</th>
<th width="161"> Destination</th>
<th width="79"> Amount</th>
<th width="41">Level</th>
<th width="41">Level2</th>
<th width="64">Remark</th>
<th width="49"> </th>
</tr>
</thead>
<?php
while($objResult = mysql_fetch_array($objQuery)){
$id = $objResult["id"];
$remark = $objResult["remark"];
$edit_class = (trim($remark) == '') ? '' : ' hide';
$tr_class = '';
#if ($objResult['level'] == '2'){
#$tr_class = ' class="tr'.$objResult['level'].'"';
#}
$style = $objResult['level'] == '2' ? 'style="background-color:red"' : '';
#echo '<tr'.$tr_class.'>';
?>
<tr <?php echo $style; ?>>
<td height="42"><div><?php echo $id;?></div></td>
<td><?php echo $objResult["reservation_date"];?></td>
<td><?php echo $objResult["destination"];?></td>
<td><?php echo $objResult["guest_name"];?></td>
<td><?php echo $objResult["amount"];?></td>
<td><?php echo $objResult["level"];?></td>
<td><?php echo $objResult["level2"];?></td>
<td><?php echo $remark;?></td>
<td bgcolor="#999999">
<div class="text-center<?php echo $edit_class;?>">
<a href="edit.php?edit_id=<?=$objResult[id]?>">EDIT</a></div></td>
</tr>
<?php
}
?>
</table>
</body>
</html>
|
|
|
|
|
Date :
2016-06-14 17:02:33 |
By :
deawx |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tbody > tr:nth-child(even) {background: #f3f3f3}.lv3_2 {background:#DAF7A6 }
tbody > tr:nth-child(odd) {background: #fff}
.lv3_2 {background:#DAF7A6 }
สีแดง ย้ายมาไว้ หลัง odd ไม่ทำตามที่บอกอะครับ
พอมันอยู่ก่อน odd มันก็จะถูก odd ทับ ครับ
ถ้าไว้หลัง odd ถ้ามีคลาสนี้ปรากฏใน tr ก็จะเปลี่ยนไปใช้ .lv3_2 ครับ
อย่าลืมเอาสีแดงออกด้วยครับ
|
|
|
|
|
Date :
2016-06-14 18:22:05 |
By :
Chaidhanan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอบความคิดเห็นที่ : 7 เขียนโดย : Chaidhanan เมื่อวันที่ 2016-06-14 18:22:05
รายละเอียดของการตอบ ::
ทำอย่างนี้ใช่ไหมครับ แต่ level2=3 ก้ยังไม่แสดง highlight ครับ
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>
<title>Untitled Document</title>
<style type="text/css">
table#gridview {
clear:both;
}
table#gridview td {
padding:3px 0px;
}
table#gridview tr.head {
background:#B18904;
font-family:Arial, Helvetica, sans-serif;
text-align:center;
}
table#gridview tr.head td {
padding:3px 0px;
}
.bb2 {
font-size: 14px;
}
text-indent:0.5in;
#gridviewsss {
color: #FFF;
}
body {
background-color: #D3D3D3;
}
body,td,th {
color: #909090;
}
thead > tr{background:#A2C4AA;}
th, td{font-family:font-family:Arial, Helvetica, sans-serif}
thead th{color:#fff;font-size:14px;}
tr{height:44px;}
tbody > tr:nth-child(even) {background: #f3f3f3}
tbody > tr:nth-child(odd) {background: #fff}
.lv3_2 {background:#DAF7A6 }
tr.tr2 {background:#FFB7B7 !important}
tbody > tr:hover, tr.tr2:hover, tr.tr3:hover{background:#fff5e6 !important}
tbody td{font-size:13px;color:#000}
tbody td > div{text-align:center}
.text-center{text-align:center}
.hide{display: none;visibility: hidden;}
</style>
<body>
<?php
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("ots_data");
$strSQL = "SELECT * FROM customer";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$strSQL .=" order by id desc ";
$objQuery = mysql_query($strSQL);
?>
<table class="display" width="800" height="135" border="0" align="center" cellpadding="1" cellspacing="1" id="gridview">
<thead> <tr>
<th width="35"> ID </th>
<th width="134" >Reservation Date</th>
<th width="212"> Guest Name</th>
<th width="161"> Destination</th>
<th width="79"> Amount</th>
<th width="41">Level</th>
<th width="64">Level2</th>
<th width="64">Remark</th>
<th width="49"> </th>
</tr>
</thead>
<?php
while($objResult = mysql_fetch_array($objQuery))
{
$id = $objResult["id"];
$remark = $objResult["remark"];
$edit_class = (trim($remark) == '') ? '' : ' hide';
$tr_class = '';
if ($objResult['level'] == '2' OR $objResult['level'] == 3)
{
$tr_class = ' class="tr'.$objResult['level'].'"';
}
echo '<tr'.$tr_class.($level3==2? ' lv3_2' : '').'>';
?>
<td height="42"><div><?php echo $id;?></div></td>
<td><?php echo $objResult["reservation_date"];?></td>
<td><?php echo $objResult["destination"];?></td>
<td><?php echo $objResult["guest_name"];?></td>
<td><?php echo $objResult["amount"];?></td>
<td><?php echo $objResult["level"];?></td>
<td><?php echo $objResult["level2"];?></td>
<td><?php echo $remark;?></td>
<td bgcolor="#999999">
<div class="text-center<?php echo $edit_class;?>">
<a href="edit.php?edit_id=<?=$objResult[id]?>">EDIT</a></div></td>
</tr>
<?php
}
?>
</table>
</body>
</html>
|
ประวัติการแก้ไข 2016-06-14 18:52:55
|
|
|
|
Date :
2016-06-14 18:50:56 |
By :
panya@ots |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>
<title>Untitled Document</title>
<style type="text/css">
table#gridview {
clear:both;
}
table#gridview td {
padding:3px 0px;
}
table#gridview tr.head {
background:#B18904;
font-family:Arial, Helvetica, sans-serif;
text-align:center;
}
table#gridview tr.head td {
padding:3px 0px;
}
.bb2 {
font-size: 14px;
}
text-indent:0.5in;
#gridviewsss {
color: #FFF;
}
body {
background-color: #D3D3D3;
}
body,td,th {
color: #909090;
}
thead > tr{background:#A2C4AA;}
th, td{font-family:font-family:Arial, Helvetica, sans-serif}
thead th{color:#fff;font-size:14px;}
tr{height:44px;}
tbody > tr:nth-child(even) {background: #f3f3f3}
tbody > tr:nth-child(odd) {background: #fff}
tr.tr2 {background:#FFB7B7 !important}
tr.tr3 {background:#0066ff !important}
tbody > tr:hover, tr.tr2:hover, tr.tr3:hover{background:#fff5e6 !important}
tbody td{font-size:13px;color:#000}
tbody td > div{text-align:center}
.text-center{text-align:center}
.hide{display: none;visibility: hidden;}
</style>
<body>
<?php
$objConnect = mysql_connect("localhost", "root", "root") or die("Error Connect to Database");
$objDB = mysql_select_db("test");
$strSQL = "SELECT * FROM customer";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$strSQL .=" ORDER BY id DESC";
$objQuery = mysql_query($strSQL);
?>
<table class="display" width="800" height="135" border="0" align="center" cellpadding="1" cellspacing="1" id="gridview">
<thead> <tr>
<th width="35">ID </th>
<th width="134">Reservation Date</th>
<th width="212">Guest Name</th>
<th width="161">Destination</th>
<th width="79">Amount</th>
<th width="41">Level</th>
<th width="64">Level2</th>
<th width="64">Remark</th>
<th width="49"> </th>
</tr>
</thead>
<?php
while($objResult = mysql_fetch_array($objQuery)) {
$id = $objResult["id"];
$remark = $objResult["remark"];
$edit_class = (trim($remark) == '') ? '' : ' hide';
$level = $objResult['level'];
$level2 = $objResult["level2"];
$tr_class = '';
if ($level == '2') {
$tr_class = ' class="tr2"';
}
else if ($level2 == '3') {
$tr_class = ' class="tr3"';
}
echo '<tr'.$tr_class.'>';
?>
<td height="42"><div><?php echo $id;?></div></td>
<td><?php echo $objResult["reservation_date"];?></td>
<td><?php echo $objResult["destination"];?></td>
<td><?php echo $objResult["guest_name"];?></td>
<td><?php echo $objResult["amount"];?></td>
<td><?php echo $level;?></td>
<td><?php echo $level2;?></td>
<td><?php echo $remark;?></td>
<td bgcolor="#999999">
<div class="text-center<?php echo $edit_class;?>">
<a href="edit.php?edit_id=<?php echo $id;?>">EDIT</a>
</div>
</td>
</tr>
<?php
}
?>
</table>
</body>
</html>
|
ประวัติการแก้ไข 2016-06-14 20:04:42
|
|
|
|
Date :
2016-06-14 20:00:25 |
By :
fossil31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo '<tr'.$tr_class.($level3==2? ' lv3_2' : '').'>';
สีแดงคุณต้องเปลี่ยน ตัวแปรให้ตรงตามความต้องการของคุณครับ
มันเป็นตัวแปรสมมติ ผมสมมติขึ้นมา ไม่ได้มีจริง
|
|
|
|
|
Date :
2016-06-14 20:02:52 |
By :
Chaidhanan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|