i want to dynamically display content in 3 bootstrap colums.
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-4">
<content>
</div> <---- Problem (should be placed at the very end of the column,
but the same code should also fill 2nd and 3rd columns)
while i fetch the query to mysql. Also i want object to sort in descending order from left to right (id = 51, id = 50, id = 42 (last digit in the object title is id)) I was able to do that, using row_number and row_number%3=0 row_number%3=1 and row_number%3=2 to display 3 columns, but i have to make 3 queries to the database along with 3 blocks of html(which is bad).
SELECT *
FROM (
SELECT
@row_number:=@row_number + 1 AS rownum, id,title, description, ...etc
FROM (
SELECT @row_number:=0) r, flats ORDER BY id DESC) ranked WHERE rownum%3=1 ORDER BY id DESC
But, when i started to implement filters, it caused problems with displaying objects, because not every column had the object i wanted to display, but i had own query for every column. Problems with filters
What i want: Dynamically form 3 separate columns with content to use one MYSQL query. Waiting for your help! Example of 1 of 3 columns:
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-4">
<?php
$zapros = $DB_con->prepare('SELECT *
FROM (
SELECT
@row_number:=@row_number + 1 AS rownum, id,title, description,type, area,address, square, name, phone, email, price, avito, farpost
FROM (
SELECT @row_number:=0) r, flats ORDER BY id DESC) ranked WHERE rownum%3=1 ORDER BY id DESC');
$zapros->execute();
$rowsone=$zapros->rowCount();
if($zapros->rowCount() > 0)
{$tmpCount = 1;
$count=$zapros->rowCount();
while($data=$zapros->fetch(PDO::FETCH_ASSOC))
{
extract($data);
$number=$data['id'];
$imagestm=$DB_con->prepare('SELECT file FROM flats_images WHERE post_id=:uid LIMIT 1');
$imagestm->bindParam(':uid',$number);
$imagestm->execute();
$imgrow=$imagestm->fetch(PDO::FETCH_ASSOC);
extract($imgrow);?>
<div class="well-lg well-smallborders">
<a href="flat.php?flat_id=<?php echo $data['id']; ?>">
<img src="/mysql/uploads/<?php echo $imgrow['file']; ?>" class="img-responsive title-image center-block" /></a>
<div class="flat-price center-block"><?php echo $data['price']; ?><span class="glyphicon glyphicon-rub" aria-hidden="true"></span> </div>
<div class="flat-title"><?php echo $data['title'];?> <?php echo $data['id']; ?></div>
<div class="dimmed-text left"><?php echo $data['type']; ?> </div>
<div class="dimmed-text right"><div class="tooltip_my"><span class="glyphicon glyphicon-map-marker" aria-hidden="true"></span><?php echo $data['area'];?> <span class="tooltiptext"><?php echo $data['address']; ?></span></div></div>
<br>
<div class="dimmed-text left"><div class="tooltip_my"> <span class="glyphicon glyphicon-phone" aria-hidden="true"></span><?php echo $data['phone'];?><span class="tooltiptext"><?php echo $data['name'];?></span></div></div>
<div class="dimmed-text right"> <?php echo $data['square'];?></div>
<table class="flats-table">
<tr>
<td colspan="3">
<button id="collapsar" class="btn btn-info pull-left" data-toggle="collapse" data-target="#hide-me<?php echo $tmpCount;?>"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> <span class="btntext">Показать миниатюры</span></button>
<a href="flat.php?flat_id=<?php echo $data['id']; ?>" class="btn btn-info pull-left" ><span class="glyphicon glyphicon-eye-open"></span> <span class="btntext">Подробнее ...</span></a>
</td>
</tr>
<tr>
<td colspan="3">
<div id="hide-me<?php echo $tmpCount;?>" class="collapse">
<?
$imagestm2=$DB_con->prepare('SELECT file FROM flats_images WHERE post_id=:uid');
$imagestm2->bindParam(':uid',$number);
$imagestm2->execute();
for ($i = 1; $i <= $imagestm2->rowCount(); $i++) {
$imgrow2=$imagestm2->fetch(PDO::FETCH_ASSOC);
extract($imgrow2); ?>
<div class="col-xs-6 col-sm-6 col-md-4 col-lg-4">
<div class="thumbnail"> <img src="mysql\uploads\<?php echo $imgrow2['file']; ?>" data-toggle="modal" data-target="#myModal" class="img-responsive"/></div>
</div>
<?
} ?>
</div>
</td>
</tr>
</table>
</div><?
$tmpCount++;
}}
?>
</div>
Actual result i want: Actual result