0
暈特定文本我這裏有我的表PHP和MySQL,HTML,CSS - 隱藏時,它有一個數據庫中的數據
sched_id sched_time sched_day emp_id
1 7:30-9:00 Monday 1
主鍵,VARCHAR(20),VARCHAR(20)和分別的外鍵。
我希望在插入數據庫中的特定數據時顯示綠色文本,並且在尚未插入數據庫時只顯示普通的普通顏色。這裏是我的工作至今
<?php
$sel_admin = " SELECT * from ehr_schedule where emp_id=".$_SESSION['emp_id']." ";
$rs_admin = mysql_query($sel_admin);
if($row = mysql_fetch_array($rs_admin))
{
?>
<td><?php if ($row['sched_stime']=="7:30-9:00")
{ ?>
<span style="color:green">7:30-9:00</span> //I have already the specific requirement and data in my database, and this display nicely
<?php } ?>
7:30-9:00 //Although, I want this to be hidden when the requirement above is meeted
<?php } ?> </td>
**警告**:如果您只是學習PHP,請不要使用['mysql_query'](http://php.net/manual/en/function.mysql-query.php)接口。這是非常可怕和危險的,它在PHP 7中被刪除了。[PDO的替代品並不難學](http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps -pdo-for-database-access /)以及[PHP The Right Way](http://www.phptherightway.com/)等指南介紹了最佳實踐。你的用戶參數是**不是** [正確轉義](http://bobby-tables.com/php),並且有[SQL注入漏洞](http://bobby-tables.com/)可以被利用。 – tadman
我有「意外的其他」的錯誤 – Noobster
@tadman謝謝你的建議 – Noobster