douji8017 2018-05-20 18:26
浏览 41
已采纳

如何在行中显示MySQL数据?

So I have a code in PHP to display MySQL database information. This is the PHP code:

<?php
$servidor = mysqli_connect ("localhost","root","");
mysqli_select_db($servidor, "produtos");

if (isset($_GET['texto'])) {
    $pesquisa = $_GET['texto'];
    $query = mysqli_query($servidor, "SELECT * FROM produtos WHERE Nome LIKE '%$pesquisa%' OR Referencia LIKE '%$pesquisa%'");

    if(mysqli_num_rows($query) > 0) {
        while($resultados = mysqli_fetch_array($query)) {
            echo "<h3>Nome: ".$resultados['Nome']."</h3>Referência: ".$resultados['Referencia']."";
        }
    } else {
        echo "<h3>Não foram encontrados resultados!</h3>";
    }
}
?>

But right now, that information is displayed in one single line, like this:

enter image description here

and I want to display it in rows, like this:

enter image description here

How can I do this in PHP?

Thank you

  • 写回答

2条回答 默认 最新

  • dongtangu8403 2018-05-20 18:35
    关注

    This part can be achieved usign HTML + CSS as @Bernhard said. Or, something that I DON'T RECOMMEND, like this:

    <div style="width:25%;float:left;padding:10px;">{item}</div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 chaquopy python 安卓
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 CSS实现渐隐虚线框
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容