Specifications
LISTING 28.6 Continued
if($items == 0)
echo “<tr>
<td colspan = “.(1+$actions).”align = center>No Items to Display</td>
</tr>”;
else
{
// print each row
for($i = 0; $items; $i++)
{
if($i%2) // background colors alternate
$bgcolor = “‘#ffffff’”;
else
$bgcolor = “‘#ccccff’”;
echo “<tr
<td bgcolor = $bgcolor
width = “. ($table_width - ($actions*149)) .”>”;
echo $list[$i][1];
if($list[$i][2])
echo “ - “.$list[$i][2];
echo “</td>”;
// create buttons for up to three actions per line
for($j = 1; $j<=3; $j++)
{
$var = ‘action’.$j;
if($$var)
{
echo “<td bgcolor = $bgcolor width = 149>”;
// view/preview buttons are a special case as they link to a file
if($$var == ‘preview-html’||$$var == ‘view-html’||
$$var == ‘preview-text’||$$var == ‘view-text’)
display_preview_button($list[$i][3], $list[$i][0], $$var);
else
display_button( $$var, “&id=” . $list[$i][0] );
echo “</td>”;
}
}
echo “</tr>\n”;
}
echo “</table>”;
}
}
This function will output a table of items, with each item having up to three associated action
buttons. The function expects five parameters, which are, in order:
Building a Mailing List Manager
C
HAPTER 28
28
BUILDING A
MAILING LIST
MANAGER
681
34 7842 CH28 3/6/01 3:46 PM Page 681