2013-08-17 60 views
0

我正在創建一個電子商務商店,我認爲我的php代碼運行良好,我可以看到我的頁面中的所有信息,但代碼干擾了我的頁腳,這裏的圖像:我的PHP代碼干擾我的頁腳

http://i.imgur.com/L99mqXl.png

我的PHP代碼的家:

http://pastebin.com/MLCWKUyy

我的PHP代碼的產品:

<?php include('cms/conectar.php'); 
?> 

<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Untitled Document</title> 
</head> 

<style> 
.prodColuna { text-align:center; width:300px; float:left; height:100% } 
</style> 


<?php 
$consulta = mysql_query("SELECT * FROM `livros-desporto` "); 

if (isset($_POST['buscar'])) { 
    $consulta = mysql_query(" 
     SELECT * FROM `livros-desporto` where name like '%".$_POST['buscar']."%' 
    "); 
} 

while ($linha = mysql_fetch_array($consulta)) { 
    $id = $linha['ID']; 
    $modelo = $linha['Model']; 
    $nome = $linha['Name']; 
    $categoria = $linha['Category']; 
    $imagem = $linha['Image']; 
    $manufactura = $linha['Manufacturer']; 
    $preco = $linha['Price']; 
    $quantidade = $linha['quantity'] 
    // $adicionar = '<a href="carrinho.php?id='.$linha['ID'].'"title="'.$linha['ID'].'"> 
    // Adicionar </a>' 
?> 
<div id="espaço"> 
    <!-- Categorias principais --> 
    <div id="baixo"> 
     <div class="prodColuna"> 
      <table width="200" height="300" border="1"> 
       <tr> 
        <th colspan="2" scope="col" height="39"><?php echo $nome ?></th> 
       </tr> 
       <tr> 
        <td height="35" colspan="2"><?php echo $preco ?></td> 
       </tr> 
       <tr> 
        <td height="184" colspan="2"><?php echo $modelo ?></td> 
       </tr> 
       <tr> 
        <td width="39"><?php echo $categoria ?></td> 
        <td width="145" height="30"><?php echo $id ?></td> 
       </tr> 
      </table> 
      <br/> 
     </div> 
<?php } ?> 
    </div> 
</div> 
</body> 
</html> 

它必須是一些標籤,我沒有關閉。

+0

我忘了我的CSS代碼:http://pastebin.com/DtVkJ68V – user2687822

+0

得到一些工具來幫助:Firebug可以幫助您揭示元素可能無法關閉的位置,並在Firefox中查看源代碼,並且如果標記無效,則會顯示紅色標記(例如,關閉的身體標記)。最後,您可以查看源代碼並將其複製粘貼到EditPad Pro等良好的文本編輯器中,語法突出顯示將使您快速查看破損標籤的位置 –

+0

@ user2687822您最好將源代碼粘貼到我們可以看到呈現的HTML。這很可能是一個HTML問題。 – Fabor

回答

0

你在while($linha = mysql_fetch_array($consulta))環出口2個的div,而不是關閉它們:

<div id="espaço"> 
<!-- Categorias principais --> 
<div id="baixo"> 

您要關閉他們的循環之外,但如果有超過1每個(例如環迭代3次),2 </div>循環外部的標籤將不會關閉所有6個打開的div標籤。你應該打開你的

<div id="espaço"> 
<!-- Categorias principais --> 
<div id="baixo"> 

高於循環,或關閉它們在循環內。

0

你缺少兩個親密的div標籤

//Your while loop start 
<div id="espaço"> 
    <div id="baixo"> 
    ... 
    //Your code - While loop is closed 
    </div> 
</div> 
//You must close while loop here not above. 

請檢查你的代碼:

<?php include('cms/conectar.php'); 
?> 

<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Untitled Document</title> 
</head> 

<style> 
.prodColuna { text-align:center; width:300px; float:left; height:100% } 
</style> 


<?php 
$consulta = mysql_query("SELECT * FROM `livros-desporto` "); 

if (isset($_POST['buscar'])) { 
    $consulta = mysql_query(" 
     SELECT * FROM `livros-desporto` where name like '%".$_POST['buscar']."%' 
    "); 
} 

while ($linha = mysql_fetch_array($consulta)) { 
    $id = $linha['ID']; 
    $modelo = $linha['Model']; 
    $nome = $linha['Name']; 
    $categoria = $linha['Category']; 
    $imagem = $linha['Image']; 
    $manufactura = $linha['Manufacturer']; 
    $preco = $linha['Price']; 
    $quantidade = $linha['quantity'] 
    // $adicionar = '<a href="carrinho.php?id='.$linha['ID'].'"title="'.$linha['ID'].'"> 
    // Adicionar </a>' 
?> 
<div id="espaço"> 
    <!-- Categorias principais --> 
    <div id="baixo"> 
     <div class="prodColuna"> 
      <table width="200" height="300" border="1"> 
       <tr> 
        <th colspan="2" scope="col" height="39"><?php echo $nome ?></th> 
       </tr> 
       <tr> 
        <td height="35" colspan="2"><?php echo $preco ?></td> 
       </tr> 
       <tr> 
        <td height="184" colspan="2"><?php echo $modelo ?></td> 
       </tr> 
       <tr> 
        <td width="39"><?php echo $categoria ?></td> 
        <td width="145" height="30"><?php echo $id ?></td> 
       </tr> 
      </table> 
      <br/> 
     </div> 
    </div> 
</div> 
<?php } ?> 
</body> 
</html>