I have business directory site, i want it to be group all post like Craigslist did.
current my data will present on the site like this
<business name1> <phone number> <jan 13 2012>
<business name2> <phone number> <jan 13 2012>
<business name1> <phone number> <jan 12 2012>
I want to layout it like this, so the posts will group by the date published.
<jan 13 2012>
<business name1> <phone number>
<business name2> <phone number>
<jan 12 2012>
<business name1> <phone number>
<business name2> <phone number>
here is my coding
connection
$query = "SELECT * FROM `myname` ORDER BY `myname`.`id` DESC LIMIT $offset, $limit ";
$result = mysql_query($query);
while($row = mysql_fetch_row($result))
{
?>
<div class="list">
<div class="ads_name"><a href="http://www.mydomain.com/category/<?=$row[0]?>.html" target="_blank"><?=$row[4]?> </a></div>
<div class="location"><?= htmlspecialchars($row[5])?></div>
<div class="phone"><?=formatPhoneNumber($row[3])?></div>
<div class="date"><?=$row[9]?></div>
</div>
<?php
}
mysql_free_result($result);
?>
GROUP BY dateclause to your query, and check the value of date as you loop the results. Every time the value changes, break the data into a new section. Without knowing more about your table schema and the desired markup output, we can't give you much of a more precise answer.