douyue9704 2014-01-26 13:53
浏览 32
已采纳

在php中从服务器在我的网站上显示图像

I'm trying to show some images on a website that I'm building. I have uploaded all the images to my server and have created a database using phpmyadmin in which I list all the path/file names for each image.

This is the code I have tried so far:

$result = mysqli_query($con,"SELECT Image,Product,Prijs,Description FROM Products order by     Product ASC LIMIT 0, 5"); 
echo '<table border="1px solid black" cellspacing="0" style="margin-top:47px"><tbody>'; 
while($row = mysqli_fetch_array($result)) 
{  
    echo "<tr>"; 
    echo "<td rowspan='2' width= '200'>" . <'img src=$row['Image']'> . "</td>"; 
    echo "<td><b>" . $row['Product'] . "</b></td>"; 
    echo "</tr>"; 
    echo "<tr>"; 
    echo "<td>" . $row['Description'] . "&nbsp;<i>Price: &euro;&nbsp;" . $row['Price'] . "</i><br/> <br/></td>"; 
    echo "</tr>"; 

}

Now it shows the product name, price, description, but no image. I'm pretty new to this so I was hoping someone here could help me out :) Any suggestions?

  • 写回答

2条回答 默认 最新

  • dongwei1855 2014-01-26 13:56
    关注

    You have a syntax error here:

    echo "<td rowspan='2' width= '200'>" . <'img src=$row['Image']'> . "</td>";

    Should be

    echo "<td rowspan='2' width= '200'><'img src='" . $row['Image'] . "'></td>";

    Needed to close the quotes before declaring the variable. Or:

    echo "<td rowspan='2' width= '200'><'img src='$row['Image']'></td>";

    don't close them. Variables can be used in double quotes.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样