PHP表现得很奇怪,混合了HTML标记

时间:2010-03-24 02:46:24

标签: php mysql while-loop

感谢您查看此问题。

我有一个完全有效页面的页面,并且有一个PHP循环为表的每个条目带来<li>

当我在本地查看此页面时,它看起来100%正常,但是当在线浏览页面时,左侧栏(创建此标记会随机混合<div><li>并且我不知道问题是什么。

这个问题出现在FF mac和PC上(safari看起来不错)

See page(问题在左侧)

php code

<?php do { ?>
    <li class="clear-block" id="<?php echo $row_Recordset1['penSKU']; ?>">
      <a title="Click to view the <?php echo $row_Recordset1['penName']; ?> collection" rel="<?php echo $row_Recordset1['penSKU']; ?>">
         <img src="prodImages/small/<?php echo $row_Recordset1['penSKU']; ?>.png" alt="" />
           <div class="prodInfoCntnr">     
                <div class="basicInfo">
                 <span class="prodName"><?php echo $row_Recordset1['penName']; ?></span> 
                 <span class="prodSku"><?php echo $row_Recordset1['penSKU']; ?></span>
                 </div>
                 <div class="secondaryInfo">
                 <span>As low as .<?php echo $row_Recordset1['price25000']; ?>¢ <!--<em>(R)</em>--></span>
                     <div class="colorPlacholder"  rel="<?php echo $row_Recordset1['penColors']; ?>"></div>
                </div>
           </div>
           <div class="additPenInfo">
               <div class="imprintInfo"><span>Imprint area: </span><?php echo $row_Recordset1['imprintArea']; ?></div>
            <div class="colorInfo"><span>Available in: </span><?php echo $row_Recordset1['penColors']; ?></div>
            <table border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <th>Amount</th>
                    <th>500</th>
                    <th>1,000</th>
                    <th>2,500</th>
                    <th>5,000</th>
                    <th>10,000</th>
                    <th>20,000</th>
                  </tr>
                  <tr>
                   <td>Price <span>(R)</span></td>
                    <td><?php echo $row_Recordset1['price500'];?>¢</td>
                    <td><?php echo $row_Recordset1['price1000'];?>¢</td>
                    <td><?php echo $row_Recordset1['price2500'];?>¢</td>
                    <td><?php echo $row_Recordset1['price5000'];?>¢</td>
                    <td>Please Contact</td>
                    <td>Please Contact</td>
                  </tr>
</table>
           </div>
    </a>
   </li>
        <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>

1 个答案:

答案 0 :(得分:5)

您无法在<div>内加<a>

Div是块级元素。锚不是。基本上,就像把<span>放在<div>之外。没有任何意义。

解决方案:将锚点移动到div内部。

(将来,如果不同的浏览器以不同的方式显示它,它可能不是PHP而是HTML。)