Jimmy Geers
Jimmy Geers

Reputation: 742

cakephp adding a <a> tag without being coded

I'm having a strange problem with cakephp. Im currently loading some data from the database into my webpage. Everything is loading like it should only from the second item that cake put's in the view it added a <a> tag <a/>

This is my html code:

    <div class="item">
<h3>xxxxx</h3>
<img class="float-left" alt="image" src="http://localhost/xxxx/xx/img/afb_07.jpg">
<p>Beschrijving: Lorem ipsum</p>
<p>
<div class="clearFloat"></div>
<p></p>
</div>

That was the first item now the second and all the next items look like this:

  <div class="item">
<h3>
<a>Second item</a>
</h3>
<a>
<img class="float-left" alt="image" src="http://localhost/xxx/cakephp2/img/afb_10.jpg">
<p>Beschrijving: xxxxxxxx</p>
</a>
<p>
<a>Datasheet: </a>
<a href="http://localhost/xxxx/cakephp2/xxxxx/xxx.pdf">
<a></a>
</p>
<div class="clearFloat"></div>
<p></p>
</div>

I also see this doctype:

<!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">

Both items are using the exact same php code to render it.

Added php code:

 if(!empty($category['Product']))
{
    foreach($category['Product'] as $product)
    {
        echo '<div class="item">';
        echo '<h3>' . $product['titel'] . '</h3>';
        echo '<img src="http://localhost/xxxx/cakephp2/img/'. $product['afbeeldingurl'] .'" class="float-left" alt="image">';
        echo '<p>' . __('Beschrijving: ') . ' ' . $product['beschrijving'] . '</p>';
        echo '<p>' . __('Datasheet: ') . '<a href="http://localhost/xxx/cakephp2/files/'.$product['datasheeturl'].'"><img src="http://localhost/xxxx/cakephp2/img/pdf.gif" alt="pdf image"><a/></p>';
        echo '<div class="clearFloat"></div>';
                echo '<p></p>';
        echo '</div>';
    }
}

Any advice?

Thanks anyway!

Upvotes: 0

Views: 231

Answers (1)

Steve
Steve

Reputation: 8640

You are closing the anchor tag incorrectly: You are using <a/> rather than </a>

It should be:

    echo '<p>' . __('Datasheet: ') . '<a href="http://localhost/xxx/cakephp2/files/'.$product['datasheeturl'].'"><img src="http://localhost/xxxx/cakephp2/img/pdf.gif" alt="pdf image"></a></p>';

Upvotes: 1

Related Questions