Mirza Alibegović
Mirza Alibegović

Reputation: 21

Link to an img inside <td> not working

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:

https://scontent-vie1-1.xx.fbcdn.net/hphotos-xta1/v/t34.0-12/11262253_1414454508878108_1351851566_n.jpg?oh=ad86bddc6f63af616e71793f3dd1e207&oe=555F5832

https://scontent-vie1-1.xx.fbcdn.net/hphotos-xta1/v/t34.0-12/11276070_1414454165544809_752028311_n.jpg?oh=30f5febf7695ac5320d696b569348df0&oe=555FAA1A

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

Answers (1)

cmorrissey
cmorrissey

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

Related Questions