L.Golden L.Golden - 1 year ago 77
HTML Question

Image not shown in table in PHP from mysql

I'm doing a small site with product descriptions for users, where the Pictures are essential for making the choice of product. It's all run xamm-server, php and mysql.
The database is running smoothly and the php gets the data from the database. In the database, there are paths to the images. I have 3 different paths in the database, one to the image, one to the root and one linking a image on the web. I end up getting a blank instead of the image. And if I look at the sourcecode for the page it looks fine. Where am I going wrong?

PHP code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
// Check connection
if (mysqli_connect_errno())
echo "Failed to connect to MySQL: " . mysqli_connect_error();
<link rel="stylesheet" href="styles.css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />



<div class="container">
<div class="sidebar1">
<ul class="nav">
<li><a href="index.html">Forside</a></li>
<li><a href="lync.html">Lync/Skype Headsets</a></li>
<li><a href="mobil.html">Mobil Headsets</a></li>
<li><a href="ip.html">IP Headsets</a></li>
<li><a href="tilbehoer.html">Tilbehør</a></li>
<li><a href="http://mitit.ccta.dk">Gå til Mit IT</a> </li>

<!-- end .sidebar1 --></div>
<div class="content">
$sql = "SELECT id, Producent, Model, kategori FROM modeller";
$result = mysqli_query($con,"SELECT * FROM `modeller");
echo "<table>";
while($row = $result->fetch_assoc())
echo "<tr>";
echo "<td>";?> <img scr="<?php echo $row["Billedurl"]; ?>"/> <?php echo "</td>";
echo "<td>" .$row["Producent"] .$row["Model"]; echo "</td>";
echo "</tr>";

echo "</table>";

<!-- end .content --></div>
<!-- end .container --></div>
<div class="footer"><br>
<!-- end .footer --></div>

Source code:

<div class="content">
<table><tr><td><img scr="headset.ccta.dk/pic/l_jabra_evolve80.jpg"/> </td><td>JabraEvolve 80 duo </td></tr>
<tr><td><img scr="skat-logo.gif"/> </td><td>JabraPro 9470</td></tr>
<tr><td><img scr="http://www.jabra.dk/-/media/Images/Products/Jabra%20Motion/Jabra_Motion_01.png"/> </td><td>PlantronicsVoyager Legend b825-m</td></tr>
<tr><td><img scr="-"/> </td><td>testtest2</td></tr></table>
<!-- end .content --></div>

Answer Source

You have got two issues here, the typo in src and lack of protocol:

<img scr="headset.ccta.dk/pic/l_jabra_evolve80.jpg"/>

it must be:

<img src="http://headset.ccta.dk/pic/l_jabra_evolve80.jpg"/>

The same goes for the other img tags.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download