13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Implementing User Functions<br />

709<br />

These three menu options activate the show-all-lists, show-other-lists, <strong>and</strong><br />

show-my-lists actions, respectively. As you have probably realized, all these actions<br />

work quite similarly.The code for these three actions is as follows:<br />

case 'show-all-lists':<br />

display_items('All Lists', get_all_lists(), 'information',<br />

'show-archive','');<br />

break;<br />

case 'show-other-lists':<br />

display_items('Unsubscribed Lists',<br />

get_unsubscribed_lists(get_email()), 'information',<br />

'show-archive', 'subscribe');<br />

break;<br />

case '':<br />

case 'show-my-lists':<br />

display_items('Subscribed Lists', get_subscribed_lists(get_email()),<br />

'information', 'show-archive', 'unsubscribe');<br />

break;<br />

As you can see, all these actions call the display_items() function from the<br />

output_fns.php library, but they each call it with different parameters.They all also use<br />

the get_email() function mentioned earlier to get the appropriate email address for this<br />

user.<br />

To see what the display_items() function does, look at Figure 30.7, the Show<br />

Other Lists page.<br />

Figure 30.7<br />

The display_items() function lays out a list of the lists that<br />

the user is not subscribed to.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!