
LISTING 28.10 Continued
$query = “select mailid, subject, listid from mail
where listid = $listid and status = ‘SENT’ order by sent”;
if(db_connect())
{
$result = mysql_query($query);
if(!$result)
{
echo “<p>Unable to get list from database - $query.”;
return false;
}
$num = mysql_numrows($result);
for($i = 0; $i<$num; $i++)
{
$row = array(mysql_result($result, $i, 0),
mysql_result($result, $i, 1), $listname, $listid);
array_push($list, $row);
}
}
return $list;
}
Again, this function gets the required information—in this case, the details of mail that has
been sent—from the database and builds an array suitable for passing to the display_items()
function.
Subscribing and Unsubscribing
On the list of mailing lists shown in Figure 28.7, each list has a button that enables users to
subscribe to it. Similarly, if users use the Show My Lists option to see the lists to which they
are already subscribed, they will see an Unsubscribe button next to each list.
These buttons activate the subscribe and unsubscribe actions, which trigger the following two
pieces of code, respectively:
case ‘subscribe’ :
{
subscribe(get_email(), $id);
display_items(“Subscribed Lists”, get_subscribed_lists(get_email()),
‘information’, ‘show-archive’, ‘unsubscribe’);
break;
}
case ‘unsubscribe’ :
{
Building a Mailing List Manager
C
HAPTER 28
28
BUILDING A
MAILING LIST
MANAGER
687
34 7842 CH28 3/6/01 3:46 PM Page 687
Comentarios a estos manuales