I have a list of dated items in a MySQL database. I need a snippet of code that will allow me to list these items by date. For instance, the list will look like this:
JULY 3RD
item 1
item 2
item 3
--------------------------------------...
HERE I WANT TO SHOW SOME TYPE OF SEPARATION BETWEEN THE DATES
--------------------------------------...
JULY 2ND
item 1
item 2
--------------------------------------...
HERE I WANT TO SHOW SOME TYPE OF SEPARATION BETWEEN THE DATES
--------------------------------------...
JULY 1ST
item 1
item 2
item 3
item 4
--------------------------------------...
HERE I WANT TO SHOW SOME TYPE OF SEPARATION BETWEEN THE DATES
--------------------------------------...
Group by date, then paginate (MySQL/php)?
$q='SELECT * FROM datetable where date like '%july%' ORDER BY date DESC';
$q=mysql_query($q);
while( $rows = mysql_fetch_array( $q )){
echo $rows[date] . '
';
if( $rows[date] != $old ){
echo '%26lt;hr /%26gt;';
}
$old = $rows[date];
}
Reply:you just need to change it to this
$q='SELECT * FROM datetable where date like '%july%' ORDER BY date DESC';
$q=mysql_query($q);
while( $rows = mysql_fetch_array( $q )){
if( $rows[date] != $old ){
echo '%26lt;hr /%26gt;';
}
$old = $rows[date];
echo $rows[date] . '
';
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment