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条)

相关推荐 更多相似问题