<?
require("config.php");
$result = mysql_query("select s_title, p_name, date from tbl_slist_info where publish='u' ORDER By date ") or die(mysql_error());
while($row=mysql_fetch_assoc($result))
{ ?>
<tr>
<td colspan="3"><?=$row['date']?></td>
</tr>
<tr>
<td><a href="g.php?title=<?=$row['s_title'] ?>"><?=$row['s_title'] ?></a></td>
<td><a href="p.php?title=<?=$row['p_name'] ?>"><?=$row['p_name'] ?></a></td>
</tr>
I want a mysql query such that I can diplay records according to dates. Suppose at 1-Jan I have 5 requests. On 2-Jan I have 4 request. IN this way
1-Jan
_____
A type1
B type1
C type2
D type1
E type3
2-Jan
____
W type4
X type1
Y type3
Z type5
It is possible to do this at the database level:
You probably should do it at the application level: When you iterate over the result set, check if the current date is different from the date of the previous row to detect group changes.
Edit based on the added PHP code in the question
So something like this: