duandaodao6951
duandaodao6951
2019-01-04 05:14

显示图像而不是变量的值[重复]

This question already has an answer here:

I'm just getting to know PHP so please bear with me if my question is not clear. I have a user registration page that collects a field called "zodiac" which is uploaded to the database. I can easily call the variable $zodiac and the value, let's say, "Aries" is displayed on the desired user's page depending on who is logged in. However, instead of the text, I'd like to display a corresponding image file on the page from my local drive. I've tried the "elseif" statements but it doesn't seem to be working. Although I do get an image with the statement it doesn't seem to change when I change users:

These are properly being loaded to the desired page:

$this->table->add_row("<b>".$username."</b>&ensp;&ensp;Age:".$age."&ensp;&ensp;".$zodiac);

if($zodiac='Aries') {
   echo '<img src="../assets/images/zodiac/Aries.png" width="45" height="35" />';
    }elseif($zodiac='Taurus') {
   echo '<img src="../assets/images/zodiac/Taurus.png" width="45" height="35" />';
    }elseif($zodiac='Gemini') {
   echo '<img src="../assets/images/zodiac/Gemini.png" width="45" height="35" />';

The "elseif" statement continues to the end.

Hope this makes sense. Thanks for any input.

</div>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

为你推荐