Sunday, November 24, 2019

fetch data from database with bootstrap


<?php
include "connect.php";
$month = date('m');
?>
<?php

$page =$_GET["page"];
$mahanghoa ="";
$mahanghoa =$_GET["mahanghoa"];
$baitren_mottrang = 3;
echo $mahanghoa;
$sql = "SELECT * FROM post ";

$result = $conn->query($sql);
if ($result->num_rows > 0) {
    // output data of each row
 $sodu_lieu = 0;

    while($row = $result->fetch_assoc()) {
$sodu_lieu++;

    }
$sotrang = $sodu_lieu/$baitren_mottrang;
}
$sotrang =ceil( $sodu_lieu/$baitren_mottrang);
$hienthi=$page*$baitren_mottrang ;
//echo "Page: ";
for ( $page = 0; $page < $sotrang; $page ++ )
{

//echo "<a href='index.php?page={$page}'>{$page}</a> ";
}
?>


     

<div class="Title"><font size='+1' color='#3B6489'><b>Bán nhà mặt phố tại Việt Nam</b></font></div>
<p>
<?php
$sql = "SELECT * FROM post order by id desc limit $hienthi,3";

$result = $conn->query($sql);
if ($result->num_rows > 0) {
    // output data of each row
 $count = 0;
    while($row = $result->fetch_assoc()) {
$id=$row["id"];
         echo "<div class='card mb-4'>";
       
           echo "<div class='card-body'>";
         //
  echo "<div class='row'>";
        echo "<div class='col-md-4 align-self-center'>";
        echo "<a  href='index.php?id=$id'><img class='img-responsive' src=".$row["image"]." alt=''  height='200' style='width:100%'  ></a>";
        echo "</div>";
        echo "<div class='col-md-8 '>";
        echo "<a  href='index.php?id=$id'><font size='+0' color='#AC253B'><b>".$row["name"]."</b></font></a>";
     //   echo "<h4>Subheading</h4>";
        echo "<p>".$row["short"]."</p>";
         //  echo "<a class='btn btn-primary' href='#'>View Project <span class='glyphicon glyphicon-chevron-right'></span></a>";
echo "<div align='right'>";     echo $row["day"];    echo "</div>";
       echo "</div>";
        echo " </div>";
 

//
          echo " </div>";
       echo "  </div>";

    }

}

?>
</p>



    <!-- /.container -->

        <!-- Pagination -->
<div>
        <ul class="pagination justify-content-center mb-4">
<!-- OLDER -->
<li class="page-item">
            <a class="page-link" href="#">&laquo;</a>
          </li>
          <li class="page-item">
   <!-- END -->
  <?php

for ( $page = 0; $page < $sotrang; $page ++ )
{
              echo "<a class='page-link' href='index.php?action=vandon&page={$page}'>{$page}</a>";
              echo "</li>";

}
?>


       
          </li>
   <!-- NEWLER -->
         <li class="page-item disabled">
            <a class="page-link" href="#">&raquo;</a>
          </li>
   <!-- END -->
        </ul>
        </ul>

      </div>

No comments:

Post a Comment