by Kevin Yank of SitePoint.com
A Challenge
As homework, see if you can figure out how to put a link labeled "Delete this Joke" next to each joke on the page that, when clicked, will remove that joke from the database and display the updated joke list. Here are a few hints to get you started:
DELETE
command, which we learned about in Part Two.
ID
column in the Jokes
table was designed to serve this purpose. You're going to have to pass the ID
of the joke to be deleted with the request to delete a joke. The query string of the "Delete this Joke" link is a perfect place to put this value.If you think you have the answer or if you would just like to see the solution, advance to the next page. Good luck!
Wrap-up
This week, we learned some new PHP functions that allow us to interface with a MySQL database server. Using these functions, we built our first database-driven Web site by publishing our Jokes database online and allowing visitors to add jokes of their own to it.
In Part Five, we go back to the MySQL command line and learn how to use relational database principles and some more advanced SQL queries to represent more complex types of information, and give our visitors credit for the jokes they add!
Challenge Solution |
SitePoint.com is a fast growing Web Developer Community. Kevin Yank is the Editor of the SitePoint TechTimes, a fresh, technically oriented newsletter for the serious Webmaster. |