我有一个表“pharma_companies”,其中有一个名为“is_approved”的列名。如果is_approved列包含0值
,我想应用样式表 <select name="current_company" id="current_company" class="validate[required]">
<option value="">Select Company</option>
<?php
$current_sql = "SELECT pharma_companies FROM pharma_companies ORDER BY pharma_companies";
$currenex = mysqli_query($db,$current_sql);
while($pharama = mysqli_fetch_assoc($currenex))
{
if($pharama['is_approved'] == '0')
{
$style = 'style = "color:red;"';
}
else
{
$style = '';
}
echo '<option value="'.$pharama['pharma_companies'].'" '.$style.'>'.$pharama['pharma_companies'].'</option>';
}
?>
</select>
但它不起作用。提前谢谢。
答案 0 :(得分:4)
您实际上从不从数据库中抓取is_approved
列。
将您的SQL更改为:
$current_sql = "SELECT pharma_companies, is_approved FROM pharma_companies ORDER BY pharma_companies";
答案 1 :(得分:0)
1)您需要获取的第一件事是批准的字段
$current_sql = "SELECT pharma_companies, is_approved FROM pharma_companies ORDER BY pharma_companies";
2)尝试条件为
if($pharama['is_approved'] == '0' || $pharama['is_approved']==0 )