使用条件语句分配变量

时间:2018-03-06 18:16:18

标签: php mysql conditional

我正在自学PHP的过程中,并且想知道在运行谷歌搜索想法的运气不佳之后我是否能从社区获得一些帮助。

我有两个文件--photos.php和profile.php

在photos.php中,我有以下内容:

if (($results[0][exterior] == "Sebring Orange Metallic") && ($results[0][model] == "Coupe") && ($results[0][ztk_performance] == "Yes") && ($results[0][wheels] == ""))
    {
        $photo='<div class="post-image details-img"><a href="images/coupe/2019-corvette-zr1-sebring-orange-ztk.jpg" class="zoom">
  <div class="mask"></div>
  <img src="images/2019-corvette-zr1-sebring-orange-ztk.jpg" alt="2019 Corvette ZR1 Coupe in Sebring Orange Metallic with the ZTK Track Performance Package" title="2019 Corvette ZR1 Coupe in Sebring Orange Metallic with the ZTK Track Performance Package"></a>
</div><br />';
    }
elseif (($results[0][exterior] == "Sebring Orange Metallic") && ($results[0][model] == "Coupe") && ($results[0][ztk_performance] == "No") && ($results[0][wheels] == ""))
{
    $photo='<div class="post-image details-img"><a href="images/coupe/2019-corvette-zr1-sebring-orange-non-ztk.jpg" class="zoom">
  <div class="mask"></div>
  <img src="images/2019-corvette-zr1-sebring-orange-ztk.jpg" alt="2019 Corvette ZR1 Coupe in Sebring Orange Metallic" title="2019 Corvette ZR1 Coupe in Sebring Orange Metallic"></a>
</div><br />';
    }

在profile.php中,我正在调用photos.php并查询数据库。我只想打印出该变量的结果:

打印$ photo;

基本上,图片没有出现,所以我试图弄清楚我的逻辑是错还是我的语法错误?

0 个答案:

没有答案
相关问题