Zoe
Zoe

Reputation: 99

extra html tag - CodeIgniter

my view page code is as below, but when i check it in the browser, it has extra <a> tag outside of the <ul> tag. I'm wondering where is the extra tag coming from????

<div class="wrapper">
    <h1>Mike&rsquo;s Full Catalog of Shirts</h1>

    <?php //$links = $this->pagination->create_links(); ?>
    <?php //echo $links; ?>

    <ul class="products">
        <?php 
        foreach($products->result() as $product){ 

            echo '<li><a href="333"><img src="'.base_url().$product->img.'" alt="'.$product->name.'"</a></li>';
        }
        ?>
    </ul>

    <?php //echo $links; ?>
</div>

the output page source is as below:

    <div class="wrapper">
        <h1>Mike’s Full Catalog of Shirts</h1>
    <ul class="products">
<li><a href="333"><img src="http://www.example.com/2015.8.5/img/shirts/shirt-113.jpg" alt="CSS3 Shirt, Black" <="" a=""></a>
</li><li><a href="333"><img src="http://www.example.com/2015.8.5/img/shirts/shirt-114.jpg" alt="PHP Shirt, Yellow" <="" a=""></a></li>
<li><a href="333"><img src="http://www.example.com/2015.8.5/img/shirts/shirt-115.jpg" alt="PHP Shirt, Purple" <="" a=""></a></li>
<li><a href="333"><img src="http://www.example.com/2015.8.5/img/shirts/shirt-116.jpg" alt="PHP Shirt, Green" <="" a=""></a></li>
<a href="333">      </a>
</ul>
<a href="333">

            </a>
</div>

here goes the controller:

function shirts()
{
    $this->load->library('pagination');

    $config['base_url'] = 'http://www.example.com/2015.8.5/index.php/home/shirts';///--to use base_url
    $config['total_rows'] = $this->db->get('products')->num_rows();
    $config['per_page'] = 8;
    $config['full_tag_open'] = '<div class="pagination">';
    $config['full_tag_close'] = '</div>';
    $config['num_links'] = 20;

    $this->pagination->initialize($config);

    $data['page_title'] = "Mike's shirts";
    $data['section'] = "shirts";

    $data['products'] = $this->db->get('products', $config['per_page'], $this->uri->segment(3));

    $this->load->view('templates/header', $data);
    $this->load->view('shirts', $data);
    $this->load->view('templates/footer', $data);
}

Upvotes: 1

Views: 128

Answers (1)

Hassaan
Hassaan

Reputation: 7662

Your <img> tag is not closed. See alt="'.$product->name.'"</a>

Change from

echo '<li><a href="333"><img src="'.base_url().$product->img.'" alt="'.$product->name.'"</a></li>';

To

echo '<li><a href="333"><img src="'.base_url().$product->img.'" alt="'.$product->name.'"></a></li>';

Upvotes: 1

Related Questions