spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / practical_php_mysql4

[previous] [next]

Subject Matter Expert - Managed Services (PA)
Next Step Systems
US-PA-Wayne

Justtechjobs.com Post A Job | Post A Resume
Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs


Building a Weblog: Part 4

Creating New Blog Entries

So far in Blogtastic, the capability to actually add a blog entry has been suspiciously missing. This essential feature requires almost all of the techniques you've seen so far, hence the delay. You are now ready, though, so it's time to knock out this page. The page behaves in a similar way to previous pages that added content, but this page also includes a drop-down combo box that is used to select the category under which the entry is filed.

Create a new file called addentry.php and start the form:

Previously, you added the entire form first, but in this page, the very first form control will be the special drop-down box just discussed:

The drop-down combo box presents a visual box with a series of options that the user can select. This involves two basic steps. First, create a <select> tag that contains the items within the box. Each item is housed within <option> tags. In these tags, add the text that you would like to appear in the box (in this case, the category name) and a value attribute. This contains the value that is passed when the user selects an item. Set this attribute to contain the ID of the category item.

In terms of making this work in code, the SQL query selects everything from the categories table. A loop iterates through the categories that are returned in the query. Within the while loop, the <option> tags are created, and the id from the query is added to the value attribute.

Complete the rest of the form:

The form is shown in Figure 4-10.

Figure 4-10

Move to the beginning of the file and add the boilerplate introductory code:

Add the logic that actually processes the form:

This code creates an INSERT query that is very similar to the ones on previous form-driven pages.

Finally, close the else block and add the footer.php code:

home / programming / practical_php_mysql4

[previous] [next]

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint

URL: