Specifications
LISTING 28.7 get_unsubscribed_lists() Function from mlm_fns.php—This Function Is Used
to Build an Array of Mailing Lists That a User Is Not Subscribed To
function get_unsubscribed_lists($email)
{
$list = array();
$query = “select lists.listid, listname, email from lists left join sub_lists
on lists.listid = sub_lists.listid
and email=’$email’ where email is NULL order by listname”;
if(db_connect())
{
$result = mysql_query($query);
if(!$result)
echo “<p>Unable to get list from database.”;
$num = mysql_numrows($result);
for($i = 0; $i<$num; $i++)
{
array_push($list, array(mysql_result($result, $i, 0),
mysql_result($result, $i, 1)));
}
}
return $list;
}
As you can see, this function requires an email address passed into it. This should be the email
address of the subscriber that we are working with. The get_subscribed_lists() function
also requires an email address as a parameter, but the get_all_lists() function does not for
obvious reasons.
Given a subscriber’s email address, we connect to the database and fetch all the lists the sub-
scriber is not subscribed to. As usual for this kind of query in MySQL, we use a LEFT JOIN to
find unmatched items.
We loop through the result and build the array row by row using the array_push() built-in
function.
Now that we know how this list is produced, let’s look at the action buttons associated with
these displays.
Viewing List Information
The Information button shown in Figure 28.7 triggers the ‘information’ action, which is as
follows:
Building a Mailing List Manager
C
HAPTER 28
28
BUILDING A
MAILING LIST
MANAGER
683
34 7842 CH28 3/6/01 3:46 PM Page 683