Specifications

LISTING 28.9 Continued
$query = “select count(*) from mail where listid = $listid
and status = ‘SENT’”;
$result = mysql_query($query);
if($result)
{
$info[‘archive’] = mysql_result($result, 0, 0);
}
return $info;
}
This function runs three database queries to collect the name and blurb for a list from the
lists table; the number of subscribers from the sub_lists table; and the number of newslet-
ters sent from the mail table.
Viewing List Archives
In addition to viewing the list blurb, users can look at all the mail that has been sent to a mail-
ing list by clicking on the Show Archive button. This activates the show-archive action, which
triggers the following code:
case ‘show-archive’ :
{
display_items(“Archive For “.get_list_name($id),
get_archive($id), ‘view-html’, ‘view-text’, ‘’);
break;
}
Again, this function uses the display_items() function to list out the various items of mail
that have been sent to the list. These items are retrieved using the
get_archive() function
from mlm_fns.php. This function is shown in Listing 28.10.
L
ISTING 28.10 get_archive() Function from mlm_fns.phpThis Function Builds an Array
of Archived Newsletters for a Given List
function get_archive($listid)
{
//returns an array of the archived mail for this list
//array has rows like (mailid, subject)
$list = array();
$listname = get_list_name($listid);
Building Practical PHP and MySQL Projects
P
ART V
686
34 7842 CH28 3/6/01 3:46 PM Page 686