0

我正在创建一个电子商务商店,我认为我的 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>

它一定是我没有关闭的一些标签。

4

2 回答 2

0

您在循环中打开 2 个 div while($linha = mysql_fetch_array($consulta)),而不是关闭它们:

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

您在循环外关闭它们,但如果每个循环超过 1 个(例如循环迭代 3 次),</div>循环外的 2 个标签不会关闭所有 6 个打开的 div 标签。你应该打开你的

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

在循环上方,或在循环内部关闭它们。

于 2013-08-17T17:35:41.290 回答
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>
于 2013-08-17T20:41:23.993 回答