PHP show articles in row's and div's repeating - php

I'm trying to create some div's that are supposed to be some articles in a webshop using bootstrap 4 alpha and PHP.
I think I need modulo (%) for this but I can't achieve what I want, I have read this and tried playing around with it but I can't get it to work, because I don't really understand what it does.
What I need is 1 row, 4 columns, and this repeating. I hope you understand where I'm going.
Here is the HTML example, there could be more rows and div's as you can see in the PHP below it:
<div class="row">
<div class="sm-col-3">
<div class="card-deck-wrapper">
<div class="card-deck">
<div class="card card-outline-secondary">
<img class="card-img-top m-x-auto d-block placeholder" src="empty.png" alt="Product">
<div class="card-block">
<h4 class="card-title">Product</h4>
<p class="card-text">
<span>Omschrijving van het product. </span><br>
<span>€ 1,00</span><br>
<span>Voorraad: 1</span>
</p>
Koop
</div>
</div>
<div class="card card-outline-secondary">
<img class="card-img-top m-x-auto d-block placeholder" src="empty.png" alt="Product">
<div class="card-block">
<h4 class="card-title">Product</h4>
<p class="card-text">
<span>Ik zal hier ook maar wat in knallen zodat niet alle kaarten even groot zijn.</span><br>
<span>€ 1,00</span><br>
<span>Voorraad: 1</span>
</p>
Koop
</div>
</div>
<div class="card card-outline-secondary">
<img class="card-img-top m-x-auto d-block placeholder" src="empty.png" alt="Product">
<div class="card-block">
<h4 class="card-title">Product</h4>
<p class="card-text">
<span>Deze kaart zal ook net even iets groter zijn om het uit te testen want ik snap er geen reet van.</span><br>
<span>€ 1,00</span><br>
<span>Voorraad: 1</span>
</p>
Koop
</div>
</div>
<div class="card card-outline-secondary">
<img class="card-img-top m-x-auto d-block placeholder" src="empty.png" alt="Product">
<div class="card-block">
<h4 class="card-title">Product</h4>
<p class="card-text">
<span>Omschrijving van het product.</span><br>
<span>€ 1,00</span><br>
<span>Voorraad: 1</span>
</p>
Koop
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="sm-col-3">
<div class="card-deck-wrapper">
<div class="card-deck">
<div class="card card-outline-secondary">
<img class="card-img-top m-x-auto d-block placeholder" src="empty.png" alt="Product">
<div class="card-block">
<h4 class="card-title">Product</h4>
<p class="card-text">
<span>Omschrijving van het product.</span><br>
<span>€ 1,00</span><br>
<span>Voorraad: 1</span>
</p>
Koop
</div>
</div>
<div class="card card-outline-secondary">
<img class="card-img-top m-x-auto d-block placeholder" src="empty.png" alt="Product">
<div class="card-block">
<h4 class="card-title">Product</h4>
<p class="card-text">
<span>Omschrijving van het product.</span><br>
<span>€ 1,00</span><br>
<span>Voorraad: 1</span>
</p>
Koop
</div>
</div>
</div>
</div>
</div>
PHP what I have now:
$categorie = mysqli_real_escape_string($mysqli, $_GET['categorie']);
$sql = "SELECT * FROM producten WHERE categorie = '$categorie' AND voorraad > 0";
$result = mysqli_query($mysqli, $sql) or die(mysqli_error($mysqli));
if (mysqli_num_rows($result) == 0) {
echo "<div class=\"card card-inverse card-warning text-xs-center\">\n";
echo " <div class=\"card-block\">\n";
echo " <blockquote class=\"card-blockquote\">\n";
echo " <span>Deze categorie bestaat niet!</span>\n";
echo " </blockquote>\n";
echo " </div>\n";
echo "</div>\n";
}
else {
echo "<h3>Categorie: " . ucfirst($_GET['categorie']) . "</h3>\n";
$i = 0;
while ($row = mysqli_fetch_array($result)) {
if ($i % 3 == 0) {
echo "<div class=\"row\">\n";
echo " <div class=\"sm-col-3\">\n";
echo " <div class=\"card-deck-wrapper\">\n";
echo " <div class=\"card-deck\">\n";
}
echo " <div class=\"card card-outline-secondary\">\n";
if ($row['plaatje'] == "") {
echo " <img class=\"card-img-top m-x-auto d-block placeholder\" src=\"empty.png\" alt=\"". $row['naam'] . "\">\n";
}
else {
echo " <img class=\"card-img-top m-x-auto d-block placeholder\" src=\"" . $row['plaatje'] . "\" alt=\"". $row['naam'] . "\">\n";
}
echo " <div class=\"card-block\">\n";
echo " <h4 class=\"card-title\">" . $row['naam'] . "</h4>\n";
echo " <p class=\"card-text\">\n";
echo " <span>" . nl2br($row['omschrijving']) . "</span><br>\n";
echo " <span>€ " . str_replace(".", ",", number_format($row['prijs'], 2)) . "</span><br>\n";
echo " <span>Voorraad: " . $row['voorraad'] . "</span><br>\n";
echo " </p>";
echo " Koop\n";
echo " </div>\n";
echo " </div>\n";
if ($i % 3 == 2) {
echo " </div>\n";
echo " </div>\n";
echo " </div>\n";
echo "</div>\n";
}
if ($i % 3 != 0) {
echo " </div>\n";
echo " </div>\n";
echo " </div>\n";
echo "</div>\n";
}
$i++;
}
It's probably a easy solution but I can't see it!
Thanks for your time.

From the link in your question, this works for me:
$i = 0;
while ($row = mysqli_fetch_array($result)) {
if ($i % 3 == 0){
echo '<div class="row">';
}
echo '<div class="col-lg-4 col-md-4 col-sm-4">';
//Your column data here
echo '</div>';
if ($i % 3 == 2){
//Close the .row div
echo '</div>';
}
$i++;
}
if ($i % 3 != 0){
//Close the .row div in case there aren't enough items left to fill up to 3
echo '</div>';
}
http://www.devchunks.com/web-development/using-the-php-modulus-operator/

Related

Bootstrap card element stretching

So the problem is that the cards are really stretching and I have tried everything to fix it and still haven't achieved the fix. Any way to fix this since I'm out of the clues? And what is the problem and where?
My container that holds cards
<div class="container mt-5">
<div class="row align-items-center">
<div class="col-sm-12 mx-auto">
<div class="card-group">
<?php
$companies = new Companies();
$companies->showAllCompanies();
?>
</div>
</div>
</div>
</div>
My PHP showAllCompanies code
public function showAllCompanies(){
$datas = $this->getAllCompanies();
foreach ($datas as $data){
$name = $data['name'];
$orgnr = $data['organization_number'];
$notes = empty($data['notes']) ? "No notes" : $data['notes'];
$id = $data['id'];
echo "
<div class='card me-2 d-block' style='width: 18rem;'>
<div class='card-body'>
<h4 class='card-title'>$name</h4>
<p class='card-text'><i class='bi bi-stickies'></i> $notes</p>
</div>
<ul class='list-group list-group-flush'>
<li class='list-group-item'>Stores Owned <span class='badge text-bg-primary'>XX</span></li>
<li class='list-group-item'>Organization Number <span
class='badge text-bg-primary'>$orgnr</span></li>
</ul>
<div class='card-body'>
<a href='#' class='btn btn-primary'>Edit</a>
<a href='#' class='btn btn-danger'>Delete</a>
</div>
</div>
";
}
return;
}
You're squeezing all your cards onto one row.
If you limit the amount of cards you display to 6 per row you can update your function to this:
public function showAllCompanies(){
$cardsPerRow = 6;
$i = 0;
$datas = $this->getAllCompanies();
foreach ($datas as $data){
$name = $data['name'];
$orgnr = $data['organization_number'];
$notes = empty($data['notes']) ? "No notes" : $data['notes'];
$id = $data['id'];
if($i == 0){
echo '<div class="row">';
}
echo "
<div class='card me-2 d-block' style='width: 18rem;'>
<div class='card-body'>
<h4 class='card-title'>$name</h4>
<p class='card-text'><i class='bi bi-stickies'></i> $notes</p>
</div>
<ul class='list-group list-group-flush'>
<li class='list-group-item'>Stores Owned <span class='badge text-bg-primary'>XX</span></li>
<li class='list-group-item'>Organization Number <span
class='badge text-bg-primary'>$orgnr</span></li>
</ul>
<div class='card-body'>
<a href='#' class='btn btn-primary'>Edit</a>
<a href='#' class='btn btn-danger'>Delete</a>
</div>
</div>
";
if(++$i >= $cardsPerRow){
echo '</div>';
$i = 0;
}
}
return;
}

PHP categories showing only one item

I'm trying to create a categories list, where user will be able to choose item with certain category, but as soon as I'm opening any of the categories, where "soon = '2'", there is only one item coming up. Everything else works.
The code bellow is for categories, where user can chose which caegory s/he want to see.
//navbar.php
<!-- Categories -->
<div class="dropdown-item menu_cat" type="button" id="catMenuButton"><i class="fas fa-caret-left"></i> Categories</div>
<form method="POST" class="dropdown-menu dropleft categories_menu row" id="cat_dropdown">
<button class="dropdown-item" name="candle"> Candles</button>
<button class="dropdown-item" name="cloth"> Clothes</button>
<button type="submit"class="dropdown-item" name="tech"> Tech</button>
</form>
Than here is everything else, that is suppose to exectute commands that will show products from category that user choose. The issue comes upp where 'if($row["soon"] == "2")' is.
//products.php
<?php
if(isset($_POST['candle'])){
$sql = "SELECT * FROM products WHERE category = 'candle'";
}else if(isset($_POST['cloth'])){
$sql = "SELECT * FROM products WHERE category = 'cloth'";
}else if(isset($_POST['tech'])){
$sql = "SELECT * FROM products WHERE category = 'tech'";
}else{
$sql = "SELECT * FROM products";
}
$result = $conn->query($sql);
if (!empty($result) && $result->num_rows > 0) {
while ($row = $result->fetch_assoc()){
if($row["soon"] == "2"){
?>
<div class="product_card col-xl-3 col-lg-4 col-md-5 col-sm-12 box-shadow">
<div class="card-header">
<h3 class="product_name my-0 font-weight-normal"> <?php echo $row["productName"] ?> </h3>
</div>
<div class="card-body">
<h2 class="card-title pricing-card-title"> </h2>
<img class="pic" src="productsImages\<?php echo $row["productID"]; ?>.jpeg" height="150px" width="120px"></img>
<br>
<p>
<?php echo $row["productPrice"]; ?> SEK
</p>
<a class="toProduct" href="products_index.php?id=<?php echo $row['productID'] ?>">
<div class="row">
<button class="btn_to_product btn btn-lg btn-outline-dark col-lg-10 col-md-10"> Go to product <i type="button" class="fas fa-arrow-alt-circle-right"></i></button>
</div>
</a>
</div>
</div>
<?php }else if($row['soon'] == "1" && isset($_POST['tech']) || isset($_POST['candle'])){?>
<div class="product_card col-xl-3 col-lg-4 col-md-5 col-sm-12 box-shadow">
<div class="card-header">
<h3 class="product_name my-0 font-weight-normal"> <?php echo $row["productName"] ?> </h3>
</div>
<div class="card-body">
<h2 class="card-title pricing-card-title"> </h2>
<img class="pic_soon" src="productsImages/comingSoon.png" height="150px" width="120px"></img>
<style>
</style>
<br>
<p>
<?php echo $row["productPrice"]; ?> SEK
</p>
<a class="toProduct" href="products_index.php?id=<?php echo $row['productID'] ?>">
<div class="row">
<button class="btn_to_product btn btn-lg btn-outline-dark col-lg-10 col-md-10"> Go to product <i type="button" class="fas fa-arrow-alt-circle-right"></i></button>
</div>
</a>
</div>
</div>
<?php
}
}
}
else if(empty($result) || $result->num_rows == 0){
echo "<h2 class='col-12'> Sorry! </h2>";
echo "<h3 class='col-12'> There is not any product in this category yet! </h3>";
}
$conn->close();
?>
In the original post was duplicate $row = $result->fetch_assoc(); statement.
In updated post there is first condition out of the while loop.
Solution bellow is wrapping all the if($row['soon'] into the while loop:
<div class="card-deck col-lg-12 col-md-12 col-sm-12 justify-content-center text-center">
<?php
if(isset($_POST['candle'])){
$sql = "SELECT * FROM products WHERE category = 'candle'";
}else if(isset($_POST['cloth'])){
$sql = "SELECT * FROM products WHERE category = 'cloth'";
}else if(isset($_POST['tech'])){
$sql = "SELECT * FROM products WHERE category = 'tech'";
}else{
$sql = "SELECT * FROM products";
}
$result = $conn->query($sql);
if (!empty($result) && $result->num_rows > 0) {
while ($row = $result->fetch_assoc()){
if($row['soon'] == "1" && isset($_POST['tech']) || isset($_POST['candle'])){
echo "<h2 class='col-12'> Sorry! </h2>";
echo "<h3 class='col-12'> This product will be soon avaiable </h3>";
}
if($row["soon"] == "2"){
?>
<div class="product_card col-xl-3 col-lg-4 col-md-5 col-sm-12 box-shadow">
<div class="card-header">
<h3 class="product_name my-0 font-weight-normal"> <?php echo $row["productName"] ?> </h3>
</div>
<div class="card-body">
<h2 class="card-title pricing-card-title"> </h2>
<img class="pic" src="productsImages\<?php echo $row["productID"]; ?>.jpeg" height="150px" width="120px"></img>
<br>
<p>
<?php echo $row["productPrice"]; ?> SEK
</p>
<a class="toProduct" href="products_index.php?id=<?php echo $row['productID'] ?>">
<div class="row">
<button class="btn_to_product btn btn-lg btn-outline-dark col-lg-10 col-md-10"> Go to product <i type="button" class="fas fa-arrow-alt-circle-right"></i></button>
</div>
</a>
</div>
</div>
<?php
}
}
}else if($result->num_rows == 0){
echo "<h2 class='col-12'> Sorry! </h2>";
echo "<h3 class='col-12'> There is not any product in this category yet! </h3>";
}
$conn->close();
?>
</div>
}
}else if($result->num_rows == 0){
echo "<h2 class='col-12'> Sorry! </h2>";
echo "<h3 class='col-12'> There is not any product in this category yet! </h3>";
}
$conn->close();
?>
</div>
Recommendation: Always debug your scripts with enabled PHP Error Reporting!
products.php
<?php
if(isset($_POST['candle'])){
$sql = "SELECT * FROM products WHERE category = 'candle'";
}else if(isset($_POST['cloth'])){
$sql = "SELECT * FROM products WHERE category = 'cloth'";
}else if(isset($_POST['tech'])){
$sql = "SELECT * FROM products WHERE category = 'tech'";
}else{
$sql = "SELECT * FROM products";
}
$result = $conn->query($sql);
if (!empty($result) && $result->num_rows > 0) {
while ($row = $result->fetch_assoc()){
if($row["soon"] == "2"){
?>
<div class="product_card col-xl-3 col-lg-4 col-md-5 col-sm-12 box-shadow">
<div class="card-header">
<h3 class="product_name my-0 font-weight-normal"> <?php echo $row["productName"] ?> </h3>
</div>
<div class="card-body">
<h2 class="card-title pricing-card-title"> </h2>
<img class="pic" src="productsImages\<?php echo $row["productID"]; ?>.jpeg" height="150px" width="120px"></img>
<br>
<p>
<?php echo $row["productPrice"]; ?> SEK
</p>
<a class="toProduct" href="products_index.php?id=<?php echo $row['productID'] ?>">
<div class="row">
<button class="btn_to_product btn btn-lg btn-outline-dark col-lg-10 col-md-10"> Go to product <i type="button" class="fas fa-arrow-alt-circle-right"></i></button>
</div>
</a>
</div>
</div>
<?php }else if($row['soon'] == "1" && isset($_POST['tech']) || isset($_POST['candle'])){?>
<div class="product_card col-xl-3 col-lg-4 col-md-5 col-sm-12 box-shadow">
<div class="card-header">
<h3 class="product_name my-0 font-weight-normal"> <?php echo $row["productName"] ?> </h3>
</div>
<div class="card-body">
<h2 class="card-title pricing-card-title"> </h2>
<img class="pic_soon" src="productsImages/comingSoon.png" height="150px" width="120px"></img>
<style>
</style>
<br>
<p>
<?php echo $row["productPrice"]; ?> SEK
</p>
<a class="toProduct" href="products_index.php?id=<?php echo $row['productID'] ?>">
<div class="row">
<button class="btn_to_product btn btn-lg btn-outline-dark col-lg-10 col-md-10"> Go to product <i type="button" class="fas fa-arrow-alt-circle-right"></i></button>
</div>
</a>
</div>
</div>
<?php
}
}
}
else if(empty($result) || $result->num_rows == 0){
echo "<h2 class='col-12'> Sorry! </h2>";
echo "<h3 class='col-12'> There is not any product in this category yet! </h3>";
}
$conn->close();
?>

bootstrap card text showing limit

i want to set a limit in my card-text to like 200 words, so it does not display the whole text in the card box field.
Is there a way to do that without script? Or when there is only a solution with script, how would you implement that in my code?
Any help would be nice, thank you!
if(mysqli_num_rows($res) > 0) { $i = 0; // Ein Zähler um zusehen, wann eine neue Reihe erstellt werden soll $beitrag .= "
<div class='album py-5 bg-light'>
<div class='container'>
<div class='row'>"; while($row = mysqli_fetch_assoc($res)) { $beitrag_id = $row['beitrag_id']; $titel = $row['titel']; $miete = $row['miete']; $einkauf = $row['einkauf']; $freizeit = $row['freizeit']; $sonstiges = $row['sonstiges']; $g_kosten = $row['g_kosten']; $p_text
= $row['p_text']; $beitrag .= "
<div class='col-md-4'>
<div class='card mb-4 box-shadow'>
<div class='card-header'>
<a href='siehe_beitrag.php?pid=$beitrag_id'>
<h4 class='my-0 font-weight-normal'>$titel</h4>
</a>
<h4 class='my-0 font-weight-normal'>$g_kosten€</h4>
</div>
<div class='card-body'>
<p class='card-text'>$p_text</p>
<div class='d-flex justify-content-between align-items-center'>
</div>
</div>"; if(isset($_SESSION["login"]) && $_SESSION["login"] == 1) { //Buttons loeschen und bearbeiten anzeigen, falls es ein angemeldeter Nutzer ist $beitrag .= "
<div class='btn-group'>
<a href='loeschen_beitrag.php?pid=$beitrag_id'>
<button type='button' class='btn btn-sm btn-outline-danger'>Loeschen</button>
<a href='bearbeiten_beitrag.php?pid=$beitrag_id'>
<button type='button' class='btn btn-sm btn-outline-secondary'>Bearbeiten</button>
</div>"; } $beitrag .= " </div>
</div>"; $i++; if($i % 3 == 0) { // Drei Ergebnisse in der div -> Starte eine neue $beitrag .= "
</div>
</div>
</div>"; $beitrag .= "
<div class='album py-5 bg-light'>
<div class='container'>
<div class='row'>"; } } if(($i - 1) % 3 != 0) { // An der letzten Schleife schließen $beitrag .= "
</div>
</div>
</div>"; }

Html Chat limit not found , also the scroll down ,

I got this code
if ($row['Sender'] == Admin ) {
echo '<div class="mesgs"> </div>';
echo '<div class="msg_history"> </div>';
echo '<div class="incoming_msg"> </div>';
echo '<div class="incoming_msg_img"><img src="https://ptetutorials.com/images/user-profile.png" alt="sunil"> </div>';
echo '<div class="received_msg"> </div>';
echo '<div class="received_withd_msg"> </div>';
echo "<p>" . $row["message"] . "</p>";
echo "<span class='time_date'>" . $row["dating"] . "</span>";
} else {
echo '<div class="mesgs"> </div>';
echo '<div class="msg_history"> </div>';
echo '<div class="outgoing_msg"> </div>';
echo '<div class="sent_msg"> </div>';
echo "<p>" . $row["message"] . "</p>";
echo "<span class='time_date'>" . $row["dating"] . "</span>";
It works fine , i'm supposed to get this
But i get this,
Like it's not in the chat , it gets out of the page , but i want a scroll down to check all the chat in the same size
the original code
<div class="mesgs">
<div class="msg_history">
<div class="incoming_msg">
<div class="incoming_msg_img"> <img src="https://ptetutorials.com/images/user-profile.png" alt="sunil"> </div>
<div class="received_msg">
<div class="received_withd_msg">
<p>Test which is a new approach to have all
solutions</p>
<span class="time_date"> 11:01 AM | June 9</span></div>
</div>
</div>
<div class="outgoing_msg">
<div class="sent_msg">
<p>Test which is a new approach to have all
solutions</p>
<span class="time_date"> 11:01 AM | June 9</span> </div>
</div>
<div class="incoming_msg">
<div class="incoming_msg_img"> <img src="https://ptetutorials.com/images/user-profile.png" alt="sunil"> </div>
<div class="received_msg">
<div class="received_withd_msg">
<p>Test, which is a new approach to have</p>
<span class="time_date"> 11:01 AM | Yesterday</span></div>
</div>
</div>
<div class="outgoing_msg">
<div class="sent_msg">
<p>Apollo University, Delhi, India Test</p>
<span class="time_date"> 11:01 AM | Today</span> </div>
</div>
<div class="incoming_msg">
<div class="incoming_msg_img"> <img src="https://ptetutorials.com/images/user-profile.png" alt="sunil"> </div>
<div class="received_msg">
<div class="received_withd_msg">
<p>We work directly with our designers and suppliers,
and sell direct to you, which means quality, exclusive
products, at a price anyone can afford.</p>
<span class="time_date"> 11:01 AM | Today</span></div>
</div>
</div>
</div>

display different image in same div in php

I want to display first image,title and description in col1 div, second in col3 and so on
but in this first image repeat in all div . how to solve this
<?php
include('connection.php');
$perPage=1;
$i=1;
if(isset($_REQUEST['act']) && trim($_REQUEST['act']=='load_data')){
$page=1;
if(!empty($_GET["page"])) {
$page = $_GET["page"];
}
$start = ($page-1)*$perPage;
if($start < 0) $start = 0;
$msg='';
$q="SELECT * FROM addimages order by id desc limit $start,$perPage ";
$res = mysql_query($q);
$row = mysql_fetch_array($res);
$id = $row['art_id'];
$qe="select banner from images where id=$id";
$rs=mysql_query($qe);
$name=mysql_fetch_array($rs);
//$id=$row['id'];
//$no=mysql_num_rows($res);
if(!$row==""){
$msg .= "<div class='article_index' id='".$row["art_id"]."'><div class='article banner_add'><a href='#'><img height='220' src='./uploads/" . $name['banner'] . "' /></a></div>";
$msg .=" <div class='post_main' >
<div class='col1'>
<div class='post_img'><a href='#'><img class='lazy' data-original='./uploads/" . $row['image'] . "' width='633' height='441' src='./uploads/" . $row['image'] . "' style='display: inline;' /></a>
</div>
<div class='post_contant_main'>
<div class='post_title'><h2><a href='#'>".$row['title']."</a></h2></div>
<div class='post_contant'>".$row['desc']."</div>
</div>
</div>";
$msg .=" <div class='col3'>
<div class='post_img'><a href='#'><img class='lazy' width='299' height='191' src='./uploads/" . $row['image'] . "' style='display: inline;' /></a>
</div>
<div class='post_contant_main'>
<div class='post_title post_rtitle'><h2><a href='#'>".$row['title']."</a></h2></div>
</div>
</div>
<div class='col3'>
<div class='post_img'><a href='#'><img class='lazy' width='299' height='191' src='./uploads/" . $row['image'] . "' style='display: inline;' /></a>
</div>
<div class='post_contant_main'>
<div class='post_title post_rtitle'><h2><a href='#'>".$row['title']."</a></h2></div>
</div>
</div>
<div class='col2'>
<div class='post_img'><a href='#'><img class='lazy' width='461' height='300' src='./uploads/" . $row['image'] . "' style='display: inline;' /></a>
</div>
<div class='post_contant_main'>
<div class='post_title'><h2><a href='#'>".$row['title']."</a></h2></div>
<div class='post_contant'>".$row['desc']."</div>
</div>
</div>
<div class='col2'>
<div class='post_img'><a href='#'><img class='lazy' width='461' height='300' src='./uploads/" . $row['image'] . "' style='display: inline;' /></a>
</div>
<div class='post_contant_main'>
<div class='post_title'><h2><a href='#'>".$row['title']."</a></h2></div>
<div class='post_contant'>".$row['desc']."</div>
</div>
</div>
</div>
</div>
";
}
$msg .="<a class='next' href='#'></a>
<input type='hidden' id='pageno' name='pageno' value=''>";
echo $msg;
}
?>
i want to increase row array to next id and display its content
i am using infinite scroll plugin
you fetch only one top row. If you want to get all rows, you need to loop it thought.
while ($row = $result->fetch_row()) {
$msg .=" <div class='post_main' >
<div class='col1'>
<div class='post_img'><a href='#'><img class='lazy' data-original='./uploads/" . $row['image'] . "' width='633' height='441' src='./uploads/" . $row['image'] . "' style='display: inline;' /></a>
</div>
<div class='post_contant_main'>
<div class='post_title'><h2><a href='#'>".$row['title']."</a></h2></div>
<div class='post_contant'>".$row['desc']."</div>
</div>
</div>";
}

Categories