
LISTING 28.8 Continued
$info = load_list_info($listid);
if($info)
{
echo “<h2>”.pretty($info[listname]).”</h2>”;
echo ‘<p>’.pretty($info[blurb]);
echo ‘<p>Number of subscribers:’ . $info[subscribers];
echo ‘<p>Number of messages in archive:’ . $info[archive];
}
}
The display_information() function uses two other functions to help it achieve its Web task:
the load_list_info() function and the pretty() function. The load_list_info() function
actually retrieves the data from the database. The pretty() function simply formats the data
from the database by stripping out slashes, turning newlines into HTML line breaks, and so on.
Let’s look briefly at the load_list_info() function. This function is in the mlm_fns.php
function library. The code for it is shown in Listing 28.9.
LISTING 28.9 load_list_info() Function from mlm_fns.php—This Function Builds an Array
of List Information
function load_list_info($listid)
{
if(!$listid)
return false;
if(!db_connect())
return false;
$query = “select listname, blurb from lists where listid = $listid”;
$result = mysql_query($query);
if(!$result)
{
echo “Cannot retrieve this list”;
return false;
}
$info = mysql_fetch_array($result);
$query = “select count(*) from sub_lists where listid = $listid”;
$result = mysql_query($query);
if($result)
{
$info[‘subscribers’] = mysql_result($result, 0, 0);
}
Building a Mailing List Manager
C
HAPTER 28
28
BUILDING A
MAILING LIST
MANAGER
685
34 7842 CH28 3/6/01 3:46 PM Page 685
Comentarios a estos manuales