05.05.2013 Views

Programming PHP

Programming PHP

Programming PHP

SHOW MORE
SHOW LESS

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

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

Example 8-4. Backend administration page (continued)<br />

<br />

<br />

<br />

<br />

When the administrator submits a new category, we construct a query to add the<br />

category to the database. Another query displays the table of all current categories.<br />

Figure 8-4 shows the page with five records loaded.<br />

Figure 8-4. The administration page<br />

Adding a Business<br />

Example 8-5 shows the page that lets a business insert data into the business and<br />

biz_categories tables. Figure 8-5 shows the form.<br />

When the user enters data and clicks on the Add Business button, the script calls<br />

itself to display a confirmation page. Figure 8-6 shows a confirmation page for a<br />

company listing assigned to two categories.<br />

In the confirmation page, the Add Business button is replaced by a link that will<br />

invoke a fresh instance of the script. A success message is displayed at the top of<br />

the page. Instructions for using the scrolling pick list are replaced with explanatory<br />

text.<br />

As shown in Example 8-5, we build the scrolling list from a query to select all the categories.<br />

As we produce HTML for each of the results from that query, we also check<br />

to see whether the current category was one of the categories submitted for the new<br />

business. If it was, we add a new record to the biz_categories table.<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.<br />

Sample Application | 207

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

Saved successfully!

Ooh no, something went wrong!