简体   繁体   中英

Display inline-block, it's working in HTML but not in PHP (I'm getting values in DB)

I find it's very strange. Even though it's working in HTML but not in PHP.

I will tell you the difference.

Here is JSFiddle for HTML.

And for PHP. The following code are below:

<div class="home-section">
    <h1> BEST SELLER </h1>
    <p>
         <form method="POST" action="cart_update.php">
         <ul class=\"home-section-img\">
        <?php
            include("config.php");  

            $current_url = base64_encode($url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
            $results = $mysqli->query("SELECT * FROM products ORDER BY id ASC");
            if ($results) {

                while($obj = $results->fetch_object())
                {

                            echo "<li>";
                            echo '  <a href="#">
                                    <img src="images/'.$obj->product_img_name.'">
                                    <p> '.$obj->price.' </p>
                                    <p> '.$obj->product_name.' </p>
                                    </a>';
                            echo "</li>";  
                }
            }
        ?>
        </ul>
        </form>
    </p>
</div>

I tried to convert from HTML to PHP. The result is display:inline-block; doesn't work in PHP. but HTML works well for display:inline-block; . The images in php should float left even though I am not using float:left; , i just want to use display:inline-block; So that I can insert pictures in database as many as I want. The images must be placed in the centered div. Any ideas?

Following line should be outside of while loop and write <form> properly .

 echo '<form method="POST" action="cart_update.php">';
 echo "<ul class=\"home-section-img\">";

and

echo "</ul>";
echo "</form>";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM