Build Your Own DatabaseDriven Website Using PHP amp;amp; MySQL [Electronic resources]

Kevin Yank

نسخه متنی -صفحه : 190/ 59
نمايش فراداده

Summary

There are a few minor tasks that our content management system is still not able to handle. For example, it's currently unable to provide a listing of all jokes that don't belong to any category—something that could come in very handy as the number of jokes in the database grows. You might also like to sort joke listings by various criteria. These particular capabilities require a few more advanced SQL tricks that we'll see in "Advanced SQL".

If we ignore these little details for the moment, you'll see that you now have a system that allows someone with no SQL or database knowledge to administer your database of jokes with ease! Together with a set of PHP-powered pages through which regular site visitors can view the jokes, this content management system allows us to set up a complete database-driven Website that can be maintained by someone with absolutely no database knowledge. And if you think that sounds like a valuable commodity to businesses looking to get on the Web today, you're right!

In fact, only one aspect of our site requires special knowledge (beyond the use of a Web browser) to use: content formatting. For example, it would not be unusual for someone to want to enter a joke that contained more than one paragraph of text. In our current system, this could be accomplished by entering the HTML code for the joke directly into the "Create New Joke" form. Why is this unacceptable?

As we stated way back in the introduction to this book, one of the most desirable features of a database-driven Website is that the people responsible for adding content to the site need not be familiar with HTML. If we require knowledge of HTML for something as simple as dividing a joke into paragraphs, we have failed to achieve our goal.

As a bonus in this chapter, you also learned a little more about arrays in PHP. You learned how a set of form elements can submit their values into a single array variable, and you learned how to process that array on the receiving end by looping through it with a while loop, a for loop, and a foreach loop.

In "Content Formatting and Submission", we'll see how we can make use of some features of PHP to provide a simpler means by which we can format content without requiring site administrators to know the ins and outs of HTML. We'll also bring back the "Submit Your Own Joke" link to our site, and discover how we can safely accept content submissions from casual site visitors.