Chapter 11. Listing, Iterating, and Administrating

For quite a while now, you’ve been focusing on some basic details: a user, the user’s information, and as an extension of that information, the user’s profile picture. You’ve become familiar with PHP and MySQL, figured out not just one but two ways to deal with one of the most common PHP issues—image loading—and you’ve managed to keep things looking good throughout. These aren’t small accomplishments; they’re very much big ones.

As a user, you can set up a profile and specify some basic information. If you’re an administrator, you might want to see how many users are in your system, delete a malicious user, or update a picture because it’s not quite socially palatable. You can do all that through your MySQL command line, but in the real world of web applications, most administrators aren’t keeping a MySQL terminal running in the corner of their monitor.

Instead, they have administrative interfaces. They can list all the users in a system; check some boxes here and there and mass delete users; and see any user they want, all through a nice, clean web interface. You can give your web application the same nice features.

When you start thinking about an administrative interface, you run into all sorts of interesting problems. You need to use different types of SQL queries. You have to mix together a lot more PHP and MySQL with your HTML because you’ll have to list every user from the database, one at a time. ...

Get PHP & MySQL: The Missing Manual, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.