0

You have got the question right Suppose that I have a div and I have to use it for 30 times in a row there is going to be variables in the which they will change their value. So my question is there anyway to create a for loop in html or php. Any Help Is much appriciated

<div class="row">
        <div class="col-lg-3">
            <div>
                <img src="images/$images[$i]">
            </div>
            <div>
                <h3>$Title[$i]</h3>
            </div>
            <div>
            <p>Ratings: 6.3/10</p>
            <p> Reviews: <?php echo $review[$i] ;?></p>
            </div>

        </div>
</div>

2 Answers2

1

Here is one way this can be done:

$content = "";
$num_divs = 30;
for ($i = 0; $i < $num_divs; $i++) {
    $content .= "<div>...</div>";
}

Then, in your html,

<?php echo $content ?>
UberRose
  • 58
  • 4
1

it can do with php

<div class="row">
     <?php for($i=0;$i<30;$i++){?>
        <div class="col-lg-3">
            <div>
                <img src=<?php echo "'images/".$images[$i]."'" ?>>
            </div>
            <div>
                <h3><?php echo $Title[$i] ?></h3>
            </div>
            <div>
            <p>Ratings: 6.3/10</p>
            <p> Reviews: <?php echo $review[$i] ;?></p>
            </div>

        </div>
     <?php } ?>
</div>