Php 将iAsset添加到代码时出现问题

Php 将iAsset添加到代码时出现问题,php,mysql,database,Php,Mysql,Database,一些解释 在我的数据库中有一列名为new_label 当它是一个新产品时,它就被设置为新的 当没有新产品时,柱是空的 当该列中没有任何内容时,我希望class=main label new label被禁用 现在,正如您从图像中看到的,即使列为空,类主标签中也始终设置了一个橙色cirkel 这是我的密码 <!-- select products from database --> <?php $query = "select * from contentwhere cat =

一些解释

在我的数据库中有一列名为new_label 当它是一个新产品时,它就被设置为新的 当没有新产品时,柱是空的

当该列中没有任何内容时,我希望class=main label new label被禁用 现在,正如您从图像中看到的,即使列为空,类主标签中也始终设置了一个橙色cirkel

这是我的密码

<!-- select products from database -->
<?php
$query = "select * from contentwhere cat = 4  order by rand() LIMIT 18";
$result = $db->query($query);
while($row = $result->fetch_array())
{
$url =detail($row);

<!-- content on main page -->
echo '
<div class="item">
<div class="product-item">
<div class="main-label new-label"><span>'.$row['new_label'].'</span></div>
<div class="product-image"><a href="'.$row['url'].'" target="_blank"><img src="'.$row['picture_big'].'" alt="'.$row['name'].'"></a></div>
<div class="product-item-details">
<div class="product-item-name"> <a href="'.$row['url'].'" target="_blank">'.$row['name'].'</a> </div>
<div class="price-box"> <span class="price">&euro;'.$row['price'].'</span> <del class="price old-price">'.$row['from_price'].'</del> </div>
                        </div>
                      </div>
                    </div>';
                            }?>
不能对表达式的结果使用isset,它只能是一个变量。事实上,如果您尝试,它将导致致命错误,这可能就是您收到500服务器错误的原因

因此,您可能可以更改这一行:

if (isset($_row['new_label']!='')) {
为此:

if (isset($_row['new_label'])) {
isset返回一个布尔值,因此将其与字符串进行比较是没有意义的

阅读更多信息:

解决了我自己,伙计们

'.$row['new_label'];}?> 无论如何谢谢你

if (isset($_row['new_label'])) {