2013-08-17 25 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>