0

I have some code that works and successfully displays some results based on an SQL query. These results are displayed in row format, however I would like to display them in columns.

Currently the results are displayed as follows

Item Details Item Details Item Details 

However I would like each result in it's own colums like so;

Item Details Item Details Item Details 

What should I change in order to do this? Do I need another foreach loop, or do I need to echo the <div class="col-md-4 col-sm-6"> and </div>

My current code is as follows.

<div class="row"> <div class="col-md-4 col-sm-6"> <?php foreach ($this->popularBook as $popularBook) { echo 'Item Details'; } ?> </div> <div class="col-md-4 col-sm-6"> <p>Item Details</p> </div> <div class="col-md-4 col-sm-6"> <p>Item Details</p> </div> </div> 

Quite new to SQL and php so any advice/direction is greatly appreciated.

0

1 Answer 1

1

Try this:

<div class='row'> <?php foreach ($this->popularBook as $idx => $popularBook) : ?> <div class='col-md-4 col-sm-6'><?php echo $popularBook-title; ?></div> <?php endforeach; ?> </div> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.