2016-01-21 17:30



I have an index.php which I have successfully filled with content from the relevant tables in a mysql database. However there is one section (events) that has a background image that is defined in the css. However after changing the css to a php and making sure to give mention <?php header("Content-type: text/css; charset: UTF-8"); ?>, background-image:url:"<?php echo $eventsrow[0]['filepath'];?>" was throwing the style of the entire document out of whack apart from not showing the image.

So i decided to put the image call in the index.php instead, as I had done for the other sections, by using inline style: <div class="monthevent" style="background-image:url("<?php echo $eventsrow[0]['filepath'];?>");">

However the image does not appear at all. Is there something wrong with this? Would appreciate any light. A var_dump on the above variable, gives the correct value: ie. the filepath, but the image is not displayed; also I tried adjusting the path relative to the css (just in case), but no image turned up. Would appreciate any thoughts on what the issue might be?

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


  • dtqjbbr5283 dtqjbbr5283 5年前

    You have to use like this:

    <div class="monthevent" style="background-image:url('<?php echo $eventsrow[0]['filepath'];?>');">

    Not the double quotes inside the url, use single quotes to differentiate the url!

    If you use double quotes:

    <div class="monthevent" style="background-image:url("");">

    If you use single quotes:

    <div class="monthevent" style="background-image:url('');">
    点赞 评论 复制链接分享