簡體   English   中英

額外的html標簽-CodeIgniter

[英]extra html tag - CodeIgniter

我的視圖頁面代碼如下,但是當我在瀏覽器中檢查它時,它在<ul>標記之外還有額外的<a>標記。 我想知道多余的標簽來自哪里?

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

輸出頁面源如下:

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

這是控制器:

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);
}

您的<img>標記未關閉。 參見alt="'.$product->name.'"</a>

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

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM