简体   繁体   English

PHP SQL-出现在div标签之外

[英]PHP SQL - appearing outside div tag

I've spent all afternoon trying to figure this out with no success, I wondered if anyone could help? 我花了整个下午试图解决这个问题,但没有成功,我想知道是否有人可以提供帮助?

I have a dropdown menu on my site which is working perfectly. 我的网站上有一个下拉菜单,可以正常运行。 I've duplicated one of the menu options and after I did this it still worked fine, it had a php / SQL query inside but once duplicate it still did what it should. 我已经复制了一个菜单选项,执行完之后它仍然可以正常工作,它里面有一个php / SQL查询,但是一旦重复它仍然可以完成它的工作。

What I did then was change the SQL and although the query is correct (checked in myphpadmin) all of my results appear out side of the div tag for some reason, its as if the div tag is closing itself. 然后,我所做的就是更改了SQL,尽管查询正确(在myphpadmin中进行了检查),但由于某种原因,我所有的结果都出现在div标记之外,就像div标记正在关闭一样。

Here's my code: ' 这是我的代码:

    <li><a href="#" class="drop">Brand</a><!-- Begin 4 columns Item -->  

      <div class="dropdown_5columns"> <!-- Begin 4 columns container -->
       <div id="top"></div>
            <div class="col_4">  
              <h2 style="width:98%;">Choose from the following Brands:</h2>  
           </div>  

    <div class="col_1" style="width:190px;">

    <?php

    $databrand = mysql_query("SELECT DISTINCT(brand), COUNT(*) as Total from `pt_products` where `brand` <>'' group by `brand` limit 5")
    or die(mysql_error()); 


    while($infobrand = mysqlfetch_array( $databrand )) 

{ 

print "<li style='width:190px;'>"; 
print "<a href='/brand'>".$infobrand['brand']." (".$infobrand['Total'].")</a></li>";

} 

print "</div>";
?>   
         <div id="bottom"></div>     
        </div><!-- End 4 columns container -->  
    </li>`

I can't seem to figure this one out. 我似乎无法弄清楚这一点。 All I did was change the SQL Query. 我所做的就是更改SQL查询。

I've tried deleting the duplicate content and starting again, but get the same outcome. 我尝试删除重复的内容并重新开始,但是得到相同的结果。

Any help would really be appreciated. 任何帮助将不胜感激。

here's the view source data on of my site: 这是我网站上的查看源数据:

<li><a href="#" class="drop">Brand</a><!-- Begin 4 columns Item -->  

<div class="dropdown_5columns" style="position:absolute;"> <!-- Begin 4 columns container -->
<div id="top"></div>
<div class="col_4">  
<h2 style="width:98%;">Choose from the following Brands:</h2>  
</div>  

<div class="col_1" style="width:190px;">
<li style='width:190px;'><a href='/brand'>Balterio (50)</a></li>
<li style='width:190px;'><a href='/brand'>Dale Hardware (24)</a></li>
<li style='width:190px;'><a href='/brand'>EuroSpec Hardware (2)</a></li>
<li style='width:190px;'><a href='/brand'>Everbuild (35)</a></li>
<li style='width:190px;'><a href='/brand'>Jeld Wen (4)</a></li>
</div>   

<div id="bottom"></div>     
</div><!-- End 4 columns container -->  
</li>

You can't tell from below but the first <li style='width:190px;'> and the </div> after the li list are higlighted in red (error) and also the last </li> 您不能从下面说出来,但是li列表后的第一个<li style='width:190px;'></div>用红色(错误)高亮显示,最后一个</li>

Thanks in advance for your help. 在此先感谢您的帮助。

You're using <li> , which should be inside a <ul> or <ol> , which you can then put inside a <div> if you need. 您正在使用<li> ,它应该位于<ul><ol> ,然后根据需要将其放入<div>内。 Alternatively, you can change the <li> to something else, such as another <div> . 另外,您可以将<li>更改为其他名称,例如另一个<div>

Your problem is like when you put a <p> directly inside a table without nesting in <tr><td> . 您的问题就像是将<p>直接放在表中而不嵌套在<tr><td>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM