View Single Post
 
Old November 30th, 2007, 11:13 PM
scottiegirl scottiegirl is offline
Authorized User
 
Join Date: Aug 2003
Location: Schuylerville, NY, USA.
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK, so I lied about when I was leaving my desk, and my hubby's not to happy about it either. I'm going to bed now, but I'll leave y'all with this tidbit.
http://www.hudsonmohawkastd.org/index-test.php
I've switched the months to be "month(curdate()) -2" in the 1st column, "month(curdate()) -1" in the second column, and "month(curdate())" in the 3rd column.FYI - In the current database, there are no entries for 2 months before (September), nor are there any for the current month (November).

1) What SHOULD happen is this: the name of the requested month will appear (in a <p></p> with a particular style sheet), then if there are no entries for that month, it will echo "No new members", otherwise, it echoes "<p><strong>first_name last_name</strong><br />company</p>". I've got the latter list to work really well.

ONE THING HERE: I want the requested month to appear just once at the top of the list.

2) Right now, my coding hinges on the YEAR(entry_date)=YEAR(curdate()). I need to change the coding so that each column reflects the actual "month(curdate()) -2", "month(curdate()) -1", or "month(curdate())". i.e., If the current date is actually February 2008, I want to have December 2007 in the 1st column, January 2008 in the 2nd column, and February 2008 in the 3rd column.

NOTE: $results are numbered "2, 3, and 4" because there is a $results call earlier in the page. Here's what I've got:
Code:
<table width="516" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="163" valign="top">
<?php
$result2 = mysql_query("SELECT id, first_name, last_name, company, monthname( entry_date ) AS monname FROM membership WHERE YEAR( entry_date ) = YEAR( curdate( ) ) AND MONTH( entry_date ) = ( MONTH( CURDATE( ) ) - 2 ) ORDER BY last_name");

if(!$result2) error_message(sql_error());

for ($ib = 0; $data = mysql_fetch_array($result2); $ib++) {
    echo "<p class=\"months\">".$data['monname']."</p>";
    if(!$data['id']) {
        echo "<p class='newbies'>No new members</p>";
    } else {
        echo "<p class='newbies'><strong>".$data['first_name']." ".$data['last_name']."</strong><br />".$data['company']."</p>";
    }
}
?>
</td>
<td width="163" valign="top">
<?php
$result3 = mysql_query("SELECT id, first_name, last_name, company, monthname( entry_date ) AS monname FROM membership WHERE YEAR( entry_date ) = YEAR( curdate( ) ) AND MONTH( entry_date ) = ( MONTH( CURDATE( ) ) - 1 ) ORDER BY last_name");

if(!$result3) error_message(sql_error());

for ($ic = 0; $data = mysql_fetch_array($result3); $ic++) {
    echo "<p class=\"months\">".$data['monname']."</p>";
    if(!$data['id']) {
        echo "<p class='newbies'>No new members</p>";
    } else {
        echo "<p class='newbies'><strong>".$data['first_name']." ".$data['last_name']."</strong><br />".$data['company']."</p>";
    }
}
?>
</td>
<td width="162" valign="top">
<?php
$result4 = mysql_query("SELECT id, first_name, last_name, company, monthname( entry_date ) AS monname FROM membership WHERE YEAR( entry_date ) = YEAR( curdate( ) ) AND MONTH( entry_date ) = MONTH( CURDATE( ) ) ORDER BY last_name");

if(!$result4) error_message(sql_error());

for ($id = 0; $data = mysql_fetch_array($result4); $id++) {
    echo "<p class=\"months\">".$data['monname']."</p>";
    if(!$data['id']) {
        echo "<p class='newbies'>No new members</p>";
    } else {
        echo "<p class='newbies'><strong>".$data['first_name']." ".$data['last_name']."</strong><br />".$data['company']."</p>";
    }
}
?>
</td>
<td width="19" valign="top"><img src="./images/spacer.gif" alt="" width="19"></td>
</tr>
</table>
Hope someone can help! Thanks in advance...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

HollyAnn
aka 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 and Hobbs