scottiegirl Posted March 13, 2008 Share Posted March 13, 2008 I am pulling membership listings from a database for a 3 month interval. Below is code to put the month as the header of each entry. I need to put the month as the header of each SECTION of entries for that month. Can someone help please? $sql = "SELECT id, first_name, last_name, company, date_format(entry_date, '%m-%d-%Y') as formatted_date, date_format(entry_date, '%M') as formatted_month FROM {$mbsp_tablename} WHERE entry_date BETWEEN DATE_SUB( CURDATE( ) ,INTERVAL 2 MONTH ) AND CURDATE( ) ORDER BY entry_date, last_name"; $result2 = mysql_query($sql) or die(mysql_error()." - error: could not connect"); while ($data = mysql_fetch_array($result2)) { echo "<span class='months'>".$data['formatted_month']."</span>"; echo "<p class='newbies'><strong>".$data['first_name']." ".$data['last_name']."</strong><br />".$data['company']."</p>"; } Thanks! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ scottiegirl "I was put on Earth to accomplish a certain number of things. Right now, I am so far behind, I will never die." - Calvin, Calvin & Hobbes Link to comment https://forums.phpfreaks.com/topic/95895-need-one-header-per-category-from-an-array/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.