Specifications

The array from get_user_urls() can be passed to display_user_urls(). This is again a sim-
ple HTML output function to print the users URLs in a nice table format, so we wont go
through it here. Refer back to Figure 24.6 to see what the output looks like. The function actu-
ally puts the URLs into a form. Next to each URL is a check box that enables bookmarks to be
marked for deletion. We will look at this next.
Deleting Bookmarks
When a user marks some bookmarks for deletion and clicks on the Delete BM option in the
menu, the form containing the URLs will be submitted. Each one of the check boxes is pro-
duced by the following code in the display_user_urls() function:
echo “<td><input type=checkbox name=\”del_me[]\”
value=\”$url\”></td>”;
The name of each input is del_me[]. This means that, in the PHP script activated by this form,
we will have access to an array called $del_me that will contain all the bookmarks to be
deleted.
Clicking on the Delete BM option activates the delete_bms.php script. This script is shown in
Listing 24.12.
LISTING 24.24 delete_bms.phpThis Script Deletes Bookmarks from the Database
<?
require_once(“bookmark_fns.php”);
session_start();
do_html_header(“Deleting bookmarks”);
check_valid_user();
if (!filled_out($HTTP_POST_VARS))
{
echo “You have not chosen any bookmarks to delete.
Please try again.”;
display_user_menu();
do_html_footer();
exit;
}
else
{
if (count($del_me) >0)
{
foreach($del_me as $url)
{
if (delete_bm($valid_user, $url))
echo “Deleted “.htmlspecialchars($url).”.<br>”;
Building Practical PHP and MySQL Projects
P
ART V
530
30 7842 ch24 3/6/01 3:34 PM Page 530