How to display multiple products in one line in php
Nov 02, 2019 am 09:55 AMphp How to display multiple products in one line
php can be used to connect to the database to query products and output the display For users, but if you want to display multiple products in one row, you need to use css technology. The specific implementation is as follows:
1. First, the php code
<?php $sql = "select * from user"; $result = $conn->query($sql); if ($result) { if ($result->num_rows>0) { echo '<div class="parent">'; while ($rows = $result->fetch_array()) { print_r($rows); echo '<div class="item">'; echo '<i>'.$rows['id'].'</i>'; echo '<img src="/static/imghw/default1.png" data-src="'.$rows['imgurl'].'" class="lazy" alt="How to display multiple products in one line in php" >'; echo '<span>'.$rows['name'].'</span>'; echo '</div>'; }//end while() echo '</div>'; }else{ echo '查询结果为空!'; }//end if() }else{ echo '查询失败!'; }//end if()
Note that there is an output div tag above, and it has class.
2. The following is the implementation of the css code
The following is the simulated database data
Note: For the flex layout involved, friends who want to learn can search for css tutorials on the php Chinese website.
Effect:
For more PHP related knowledge, please visit PHP Chinese website!
The above is the detailed content of How to display multiple products in one line in php. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

How To Set Up Visual Studio Code (VS Code) for PHP Development
