how to display 3 columns dynamic data from database using bootstrap 4












0















Following is my code I am displaying details as 3 columns per row using Bootstrap class row.



I tried like changing div and some condition



<div class="container">
<?php

if($lclResult->rowCount() > 0){
while($row = $lclResult->fetch(PDO::FETCH_ASSOC)) {
# code...
$lclUserName = $row['us_business_name'];
$lclImage1 = $row['us_image1'];
$lclCategory = $row['us_category'];
$lclArea = $row['us_area'];

?>
<div class="row">
<div class="col-sm-4">
<div class="card">
<img class="card-img-top " src="<?php echo $lclImage1 ?>" alt="Card image" style="width:100%; height: 158px;">
<div class="card-body">
<h4 class="card-title"><?php echo $lclUserName?></h4>
<p class="card-text" style="font-size: 25px;"><?php echo $lclCategory?></p>
<hr>
<i class="fa fa-map-marker" style="font-size: 23px;"><span>&nbsp;&nbsp;</span><?php echo $lclArea?></i>
<!-- <a href="#" class="btn btn-primary">See Profile</a> -->

</div>
</div>


<?php
}
?>
</div>
<?php
} else {
?>
<div class="container">
<div class="row">
<div class="col-sm-12">
<h1> NO RESULT FOUND...</h1>
</div>
</div>
</div>

<?php
}
?>


</div>
</div>


I want to display 3 columns per row to display data. If anyone knows Please guide me with the above code.










share|improve this question

























  • your <div class="col-sm-4"> should be the inner of your foreach loop, you're printing a whole row container each iteration.

    – Scuzzy
    Jan 1 at 9:28











  • if you see I am using <div class="col-sm-4"> inside of while loop

    – ALPHA
    Jan 1 at 9:33











  • <div class="row"> should be the outer

    – Scuzzy
    Jan 1 at 9:35
















0















Following is my code I am displaying details as 3 columns per row using Bootstrap class row.



I tried like changing div and some condition



<div class="container">
<?php

if($lclResult->rowCount() > 0){
while($row = $lclResult->fetch(PDO::FETCH_ASSOC)) {
# code...
$lclUserName = $row['us_business_name'];
$lclImage1 = $row['us_image1'];
$lclCategory = $row['us_category'];
$lclArea = $row['us_area'];

?>
<div class="row">
<div class="col-sm-4">
<div class="card">
<img class="card-img-top " src="<?php echo $lclImage1 ?>" alt="Card image" style="width:100%; height: 158px;">
<div class="card-body">
<h4 class="card-title"><?php echo $lclUserName?></h4>
<p class="card-text" style="font-size: 25px;"><?php echo $lclCategory?></p>
<hr>
<i class="fa fa-map-marker" style="font-size: 23px;"><span>&nbsp;&nbsp;</span><?php echo $lclArea?></i>
<!-- <a href="#" class="btn btn-primary">See Profile</a> -->

</div>
</div>


<?php
}
?>
</div>
<?php
} else {
?>
<div class="container">
<div class="row">
<div class="col-sm-12">
<h1> NO RESULT FOUND...</h1>
</div>
</div>
</div>

<?php
}
?>


</div>
</div>


I want to display 3 columns per row to display data. If anyone knows Please guide me with the above code.










share|improve this question

























  • your <div class="col-sm-4"> should be the inner of your foreach loop, you're printing a whole row container each iteration.

    – Scuzzy
    Jan 1 at 9:28











  • if you see I am using <div class="col-sm-4"> inside of while loop

    – ALPHA
    Jan 1 at 9:33











  • <div class="row"> should be the outer

    – Scuzzy
    Jan 1 at 9:35














0












0








0








Following is my code I am displaying details as 3 columns per row using Bootstrap class row.



I tried like changing div and some condition



<div class="container">
<?php

if($lclResult->rowCount() > 0){
while($row = $lclResult->fetch(PDO::FETCH_ASSOC)) {
# code...
$lclUserName = $row['us_business_name'];
$lclImage1 = $row['us_image1'];
$lclCategory = $row['us_category'];
$lclArea = $row['us_area'];

?>
<div class="row">
<div class="col-sm-4">
<div class="card">
<img class="card-img-top " src="<?php echo $lclImage1 ?>" alt="Card image" style="width:100%; height: 158px;">
<div class="card-body">
<h4 class="card-title"><?php echo $lclUserName?></h4>
<p class="card-text" style="font-size: 25px;"><?php echo $lclCategory?></p>
<hr>
<i class="fa fa-map-marker" style="font-size: 23px;"><span>&nbsp;&nbsp;</span><?php echo $lclArea?></i>
<!-- <a href="#" class="btn btn-primary">See Profile</a> -->

</div>
</div>


<?php
}
?>
</div>
<?php
} else {
?>
<div class="container">
<div class="row">
<div class="col-sm-12">
<h1> NO RESULT FOUND...</h1>
</div>
</div>
</div>

<?php
}
?>


</div>
</div>


I want to display 3 columns per row to display data. If anyone knows Please guide me with the above code.










share|improve this question
















Following is my code I am displaying details as 3 columns per row using Bootstrap class row.



I tried like changing div and some condition



<div class="container">
<?php

if($lclResult->rowCount() > 0){
while($row = $lclResult->fetch(PDO::FETCH_ASSOC)) {
# code...
$lclUserName = $row['us_business_name'];
$lclImage1 = $row['us_image1'];
$lclCategory = $row['us_category'];
$lclArea = $row['us_area'];

?>
<div class="row">
<div class="col-sm-4">
<div class="card">
<img class="card-img-top " src="<?php echo $lclImage1 ?>" alt="Card image" style="width:100%; height: 158px;">
<div class="card-body">
<h4 class="card-title"><?php echo $lclUserName?></h4>
<p class="card-text" style="font-size: 25px;"><?php echo $lclCategory?></p>
<hr>
<i class="fa fa-map-marker" style="font-size: 23px;"><span>&nbsp;&nbsp;</span><?php echo $lclArea?></i>
<!-- <a href="#" class="btn btn-primary">See Profile</a> -->

</div>
</div>


<?php
}
?>
</div>
<?php
} else {
?>
<div class="container">
<div class="row">
<div class="col-sm-12">
<h1> NO RESULT FOUND...</h1>
</div>
</div>
</div>

<?php
}
?>


</div>
</div>


I want to display 3 columns per row to display data. If anyone knows Please guide me with the above code.







php html bootstrap-4






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 1 at 9:32







ALPHA

















asked Jan 1 at 9:13









ALPHAALPHA

14




14













  • your <div class="col-sm-4"> should be the inner of your foreach loop, you're printing a whole row container each iteration.

    – Scuzzy
    Jan 1 at 9:28











  • if you see I am using <div class="col-sm-4"> inside of while loop

    – ALPHA
    Jan 1 at 9:33











  • <div class="row"> should be the outer

    – Scuzzy
    Jan 1 at 9:35



















  • your <div class="col-sm-4"> should be the inner of your foreach loop, you're printing a whole row container each iteration.

    – Scuzzy
    Jan 1 at 9:28











  • if you see I am using <div class="col-sm-4"> inside of while loop

    – ALPHA
    Jan 1 at 9:33











  • <div class="row"> should be the outer

    – Scuzzy
    Jan 1 at 9:35

















your <div class="col-sm-4"> should be the inner of your foreach loop, you're printing a whole row container each iteration.

– Scuzzy
Jan 1 at 9:28





your <div class="col-sm-4"> should be the inner of your foreach loop, you're printing a whole row container each iteration.

– Scuzzy
Jan 1 at 9:28













if you see I am using <div class="col-sm-4"> inside of while loop

– ALPHA
Jan 1 at 9:33





if you see I am using <div class="col-sm-4"> inside of while loop

– ALPHA
Jan 1 at 9:33













<div class="row"> should be the outer

– Scuzzy
Jan 1 at 9:35





<div class="row"> should be the outer

– Scuzzy
Jan 1 at 9:35












1 Answer
1






active

oldest

votes


















0














Change your code like this



<div class="container">
<div class="row">
<?php
if($lclResult->rowCount() > 0){
while($row = $lclResult->fetch(PDO::FETCH_ASSOC)) {
# code...
$lclUserName = $row['us_business_name'];
$lclImage1 = $row['us_image1'];
$lclCategory = $row['us_category'];
$lclArea = $row['us_area'];
?>
<div class="col-sm-4">
<div class="card">
<img class="card-img-top " src="<?php echo $lclImage1 ?>" alt="Card image" style="width:100%; height: 158px;">
<div class="card-body">
<h4 class="card-title">
<?php echo $lclUserName?>
</h4>
<p class="card-text" style="font-size: 25px;">
<?php echo $lclCategory?>
</p>
<hr>
<i class="fa fa-map-marker" style="font-size: 23px;">
<span>&nbsp;&nbsp;
</span>
<?php echo $lclArea?>
</i>
<!-- <a href="#" class="btn btn-primary">See Profile</a> -->
</div>
</div>
</div>
<?php
}
?>
<?php
} else {
?>
<div class="container">
<div class="row">
<div class="col-sm-12">
<h1> NO RESULT FOUND...
</h1>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53994258%2fhow-to-display-3-columns-dynamic-data-from-database-using-bootstrap-4%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Change your code like this



    <div class="container">
    <div class="row">
    <?php
    if($lclResult->rowCount() > 0){
    while($row = $lclResult->fetch(PDO::FETCH_ASSOC)) {
    # code...
    $lclUserName = $row['us_business_name'];
    $lclImage1 = $row['us_image1'];
    $lclCategory = $row['us_category'];
    $lclArea = $row['us_area'];
    ?>
    <div class="col-sm-4">
    <div class="card">
    <img class="card-img-top " src="<?php echo $lclImage1 ?>" alt="Card image" style="width:100%; height: 158px;">
    <div class="card-body">
    <h4 class="card-title">
    <?php echo $lclUserName?>
    </h4>
    <p class="card-text" style="font-size: 25px;">
    <?php echo $lclCategory?>
    </p>
    <hr>
    <i class="fa fa-map-marker" style="font-size: 23px;">
    <span>&nbsp;&nbsp;
    </span>
    <?php echo $lclArea?>
    </i>
    <!-- <a href="#" class="btn btn-primary">See Profile</a> -->
    </div>
    </div>
    </div>
    <?php
    }
    ?>
    <?php
    } else {
    ?>
    <div class="container">
    <div class="row">
    <div class="col-sm-12">
    <h1> NO RESULT FOUND...
    </h1>
    </div>
    </div>
    </div>
    <?php
    }
    ?>
    </div>
    </div>





    share|improve this answer




























      0














      Change your code like this



      <div class="container">
      <div class="row">
      <?php
      if($lclResult->rowCount() > 0){
      while($row = $lclResult->fetch(PDO::FETCH_ASSOC)) {
      # code...
      $lclUserName = $row['us_business_name'];
      $lclImage1 = $row['us_image1'];
      $lclCategory = $row['us_category'];
      $lclArea = $row['us_area'];
      ?>
      <div class="col-sm-4">
      <div class="card">
      <img class="card-img-top " src="<?php echo $lclImage1 ?>" alt="Card image" style="width:100%; height: 158px;">
      <div class="card-body">
      <h4 class="card-title">
      <?php echo $lclUserName?>
      </h4>
      <p class="card-text" style="font-size: 25px;">
      <?php echo $lclCategory?>
      </p>
      <hr>
      <i class="fa fa-map-marker" style="font-size: 23px;">
      <span>&nbsp;&nbsp;
      </span>
      <?php echo $lclArea?>
      </i>
      <!-- <a href="#" class="btn btn-primary">See Profile</a> -->
      </div>
      </div>
      </div>
      <?php
      }
      ?>
      <?php
      } else {
      ?>
      <div class="container">
      <div class="row">
      <div class="col-sm-12">
      <h1> NO RESULT FOUND...
      </h1>
      </div>
      </div>
      </div>
      <?php
      }
      ?>
      </div>
      </div>





      share|improve this answer


























        0












        0








        0







        Change your code like this



        <div class="container">
        <div class="row">
        <?php
        if($lclResult->rowCount() > 0){
        while($row = $lclResult->fetch(PDO::FETCH_ASSOC)) {
        # code...
        $lclUserName = $row['us_business_name'];
        $lclImage1 = $row['us_image1'];
        $lclCategory = $row['us_category'];
        $lclArea = $row['us_area'];
        ?>
        <div class="col-sm-4">
        <div class="card">
        <img class="card-img-top " src="<?php echo $lclImage1 ?>" alt="Card image" style="width:100%; height: 158px;">
        <div class="card-body">
        <h4 class="card-title">
        <?php echo $lclUserName?>
        </h4>
        <p class="card-text" style="font-size: 25px;">
        <?php echo $lclCategory?>
        </p>
        <hr>
        <i class="fa fa-map-marker" style="font-size: 23px;">
        <span>&nbsp;&nbsp;
        </span>
        <?php echo $lclArea?>
        </i>
        <!-- <a href="#" class="btn btn-primary">See Profile</a> -->
        </div>
        </div>
        </div>
        <?php
        }
        ?>
        <?php
        } else {
        ?>
        <div class="container">
        <div class="row">
        <div class="col-sm-12">
        <h1> NO RESULT FOUND...
        </h1>
        </div>
        </div>
        </div>
        <?php
        }
        ?>
        </div>
        </div>





        share|improve this answer













        Change your code like this



        <div class="container">
        <div class="row">
        <?php
        if($lclResult->rowCount() > 0){
        while($row = $lclResult->fetch(PDO::FETCH_ASSOC)) {
        # code...
        $lclUserName = $row['us_business_name'];
        $lclImage1 = $row['us_image1'];
        $lclCategory = $row['us_category'];
        $lclArea = $row['us_area'];
        ?>
        <div class="col-sm-4">
        <div class="card">
        <img class="card-img-top " src="<?php echo $lclImage1 ?>" alt="Card image" style="width:100%; height: 158px;">
        <div class="card-body">
        <h4 class="card-title">
        <?php echo $lclUserName?>
        </h4>
        <p class="card-text" style="font-size: 25px;">
        <?php echo $lclCategory?>
        </p>
        <hr>
        <i class="fa fa-map-marker" style="font-size: 23px;">
        <span>&nbsp;&nbsp;
        </span>
        <?php echo $lclArea?>
        </i>
        <!-- <a href="#" class="btn btn-primary">See Profile</a> -->
        </div>
        </div>
        </div>
        <?php
        }
        ?>
        <?php
        } else {
        ?>
        <div class="container">
        <div class="row">
        <div class="col-sm-12">
        <h1> NO RESULT FOUND...
        </h1>
        </div>
        </div>
        </div>
        <?php
        }
        ?>
        </div>
        </div>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 1 at 9:33









        Shafikur RahmanShafikur Rahman

        1,90931125




        1,90931125
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53994258%2fhow-to-display-3-columns-dynamic-data-from-database-using-bootstrap-4%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas