php - div 在 php 中 while 循环

标签 php html css twitter-bootstrap

搜索结果应该像这样显示 enter image description here

但我的结果叠加在每个结果之上。 enter image description here

这是我的代码:

<div class="container">

<?php
    mysql_connect("localhost", "root", "") or die(mysql_error());
    mysql_select_db("thesis") or die(mysql_error());

    $search = trim( $_POST['SearchKeywords']);

    $query = " SELECT * FROM new_data WHERE Product_Title or Product_link LIKE'%$search%' "; 

    $sql = mysql_query($query) or die(mysql_error());
    $count = mysql_num_rows($sql);

    $count == 0;

    if ($count == 0) {

        echo "Sorry, Nothing Found !!";

    }else{

    while ($row = mysql_fetch_array($sql)) 
    {
        $img = $row ['Product_Img'];
        $link = $row ['Product_link'];
        $title = $row ['Product_Title'];
        $price = $row ['Product_Price'];
?>

<div class="card"> 
  <div class="front alert alert-success"> 
    <?php echo "$title"; 
         echo "<img src='$img' width='80px' height='100px'>"; 
         echo "$price"; ?> 
  </div> 
</div>
<?php
     };
    };
?>
</div>  <!-- Container -->

那些div block 在容器 中。 为了更好的设计,我添加了一个 Bootstrap 类。

最佳答案

您可以使用 thumbnails with custom content

<div class="row">
  <div class="col-sm-6 col-md-4">
    <div class="thumbnail">
      <img src="..." alt="...">
      <div class="caption">
        <h3>Thumbnail label</h3>
        <p>...</p>
        <p><a href="#" class="btn btn-primary" role="button">Button</a> <a href="#" class="btn btn-default" role="button">Button</a></p>
      </div>
    </div>
  </div>
</div>

关于php - div 在 php 中 while 循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32165787/

相关文章:

PHP多数据库连接

html - webkit 在调整大小时 float 闪烁

媒体查询中的 CSS3 转换?

css - 如何在 IE 7 中水平放置此选项卡?

css - 为什么设置显示:none to an element inside inline-block div make inline-block not render as an inline-block;

php - 当信息不恒定时从 WP 数据库获取数据

javascript - Braintree - paymentMethodNonceReceived 未被调用

PHP获取月份的周数

javascript - 在 Jquery 中创建的变量未出现在调试器中

html - 使用 XSL 文件解析 CDATA block 内的 HTML