Jump to content

Need one header per category from an array


scottiegirl

Recommended Posts

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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.