Reputation: 21
I have a huge issue with clicking and opening an image inside table. I created mysql database and implemented via php in table on my site. Everything works just fine except images. They are showing up as a thumbails on table (and they should be, because I put height very small) but when I want to click on them, nothing happens, it just don't wanna go on that place where the image is located (even though the link to the image appears on bottom of the browser and my cursor goes in "link" mode).
That part of my PHP code:
echo "<table class=table>
<tr>
<th><b>ID:</b></th>
<th><b>Ime:</b></th>
<th><b>Dimenzije-cm:</b></th>
<th><b>Kol.po-m2:</b></th>
<th><b>Težina-kg/m2:</b></th>
<th><b>Na paleti-m2:</b></th>
<th><b>Slike:</b></th>";
while ($record = mysqli_fetch_array($myData)){
echo "<tr>";
echo "<td>" . $record['id'] . "</td>";
echo "<td>" . $record['ime'] . "</td>";
echo "<td>" . $record['dimenzije-cm'] . "</td>";
echo "<td>" . $record['kol.po-m2'] . "</td>";
echo "<td>" . $record['tezina-kg/m2'] . "</td>";
echo "<td>" . $record['na paleti-m2'] . "</td>";
echo "<td><a href=" . $record['images'] . " > <img src=" . $record['images'] . " height=30px;></a></td>";
}
Here is image how it looks like live:
As you can see in my code, link for <img src
and <a href
is the same (the image is the same one - 1.jpg) and the location is good, but it don't want to click and go on image inside localhost/1.jpg)..
I created the site using Bootstrap, so maybe there is something in css for table imgs that creates the problem? Help me please..
And yes, I tried creating new .php file and just c/p PHP code in it, and it works perfectly.. It opens my image when I click on it just as it should be.
Upvotes: 0
Views: 1150
Reputation: 8583
Change this line
echo "<td><a href=" . $record['images'] . " >
<img src=" . $record['images'] . " height=30px;></a></td>";
to
echo "<td><a href=\"" . $record['images'] . "\" >
<img src=\"" . $record['images'] . "\" height=\"30\" /></a></td>";
note the escaped \"
Upvotes: 1