dongtiao0279 2015-07-29 14:49
浏览 6
已采纳

无法在页面上使用php显示图片

I am trying to dynamically display a picture based on the the entry on the database. I can see i am able to build the url from where the picture has to be fetched but it doesn't display the picture.. I am not able to figure out what is happening.. any help will be appreciated.

             // Connect to the database
             $dbhost = 'localhost';
             $dbusername = 'vote';
             $dbpasswd = 'vote';
             $database_name = 'vote_active';
             $connection = mysql_connect("$dbhost","$dbusername","$dbpasswd")
              or die ('Couldn\'t connect to server.');
             $db = mysql_select_db("$database_name", $connection)
              or die('Couldn\'t select database.');

             $sqlMain = ("SELECT DISTINCT number, comments, Engineer, votes FROM active_nomination;");
             $lqlMain = mysql_query($sqlMain) or die(mysql_error());
             while($lplMain = mysql_fetch_assoc($lqlMain)){
                 $enge = utf8_encode($lplMain['Engineer']);
                //print $enge;
                $url= "http://wwwin.kabi.com/dir/photo/prof/$enge.jpg";
                print $url;
                echo
                '<td>;
                <img src="<?php $url ?>"  />
                </td>';
             }
                ?>
  • 写回答

1条回答 默认 最新

  • doulv8162 2015-07-29 15:01
    关注

    Change the echo line to

    echo '<td><img src="'.$url.'"  /></td>';
    

    You were not properly string concatenating. Also there is no need for wrapping variables within php tags when you are already within the PHP block.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 像这种代码要怎么跑起来?
  • ¥15 怎么改成循环输入删除(语言-c语言)
  • ¥15 安卓C读取/dev/fastpipe屏幕像素数据
  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection
  • ¥15 nginx代理报502的错误
  • ¥100 当AWR1843发送完设置的固定帧后,如何使其再发送第一次的帧
  • ¥15 图示五个参数的模型校正是用什么方法做出来的。如何建立其他模型
  • ¥100 描述一下元器件的基本功能,pcba板的基本原理
  • ¥15 STM32无法向设备写入固件