Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 为什么柱子都堆起来了?_Php_Html_Mysql_Css - Fatal编程技术网

Php 为什么柱子都堆起来了?

Php 为什么柱子都堆起来了?,php,html,mysql,css,Php,Html,Mysql,Css,我正在开一家小店,我有一个展示我产品的页面。此页面的代码如下所示: <?php error_reporting(E_ALL); ini_set('display_errors', 1); if(isset($_GET['action']) && $_GET['action']=="add"){ $id=($_GET['id']); if(isset($_SESSION['cart'][$id])){

我正在开一家小店,我有一个展示我产品的页面。此页面的代码如下所示:

<?php

    error_reporting(E_ALL); ini_set('display_errors', 1);

    if(isset($_GET['action']) && $_GET['action']=="add"){

        $id=($_GET['id']);

        if(isset($_SESSION['cart'][$id])){

            $_SESSION['cart'][$id]['quantity']++;

        }else{

            $sql_s="SELECT * FROM products
                WHERE productCode='{$id}'";
            $query_s=mysql_query($sql_s) or die(mysql_error());
            if(mysql_num_rows($query_s)!=0){
                $row_s=mysql_fetch_array($query_s);

                $_SESSION['cart'][$row_s['productCode']]=array(
                        "quantity" => 1,
                        "price" => $row_s['buyPrice']
                    );


            }else{

                $message="This product id it's invalid!";

            }

        }

    }

?>
    <h1>Classic Cars</h1>
    <?php
        if(isset($message)){
            echo "<h2>$message</h2>";
        }
    ?>
        <div class="container">

                <?php

                    $sql="SELECT * FROM products ORDER BY productName ASC";
                    $query=mysql_query($sql) or die(mysql_error());

                    while ($row=mysql_fetch_array($query)) {

                ?>
                    <div class="row">
                        <div class="col-xs-12 col-sm-4 col-md-3">
                            <div class="recent-work-wrap">
                                <img class="img-responsive" src="images/portfolio/recent/item1.png" alt="">
                                <div class="overlay">
                                    <div class="recent-work-inner">
                                        <h3><a href="#"><?php echo $row['productName'] ?></a> </h3>
                                        <p>€<?php echo $row['buyPrice'] ?></p>
                                        <a class="btn btn-login" href="register.php">Add to cart</i></a>
                                        <a class="btn btn-login" href="register.php">Read more</i></a>
                                    </div> 
                                </div>
                            </div>
                        </div>   
                    </div>

                <?php

                    }

                ?>
        </div>
代码的结果如下所示:

<?php

    error_reporting(E_ALL); ini_set('display_errors', 1);

    if(isset($_GET['action']) && $_GET['action']=="add"){

        $id=($_GET['id']);

        if(isset($_SESSION['cart'][$id])){

            $_SESSION['cart'][$id]['quantity']++;

        }else{

            $sql_s="SELECT * FROM products
                WHERE productCode='{$id}'";
            $query_s=mysql_query($sql_s) or die(mysql_error());
            if(mysql_num_rows($query_s)!=0){
                $row_s=mysql_fetch_array($query_s);

                $_SESSION['cart'][$row_s['productCode']]=array(
                        "quantity" => 1,
                        "price" => $row_s['buyPrice']
                    );


            }else{

                $message="This product id it's invalid!";

            }

        }

    }

?>
    <h1>Classic Cars</h1>
    <?php
        if(isset($message)){
            echo "<h2>$message</h2>";
        }
    ?>
        <div class="container">

                <?php

                    $sql="SELECT * FROM products ORDER BY productName ASC";
                    $query=mysql_query($sql) or die(mysql_error());

                    while ($row=mysql_fetch_array($query)) {

                ?>
                    <div class="row">
                        <div class="col-xs-12 col-sm-4 col-md-3">
                            <div class="recent-work-wrap">
                                <img class="img-responsive" src="images/portfolio/recent/item1.png" alt="">
                                <div class="overlay">
                                    <div class="recent-work-inner">
                                        <h3><a href="#"><?php echo $row['productName'] ?></a> </h3>
                                        <p>€<?php echo $row['buyPrice'] ?></p>
                                        <a class="btn btn-login" href="register.php">Add to cart</i></a>
                                        <a class="btn btn-login" href="register.php">Read more</i></a>
                                    </div> 
                                </div>
                            </div>
                        </div>   
                    </div>

                <?php

                    }

                ?>
        </div>
为什么柱子都堆起来了?如何解决这个问题?

HTML:

<img class="img-responsive inline-block" src="images/portfolio/recent/item1.png" alt="">

您可以尝试使用此CSS属性创建图像:

img{
display: inline-block;
float:left;
}

请在浏览器中显示生成的HTML右键单击->显示页面源代码,而不是PHP代码。