onChange="attach_file( 'helper.php?category_id=' +
Another way of stating the above code would be to say that each time a “Categories” option is selected, the “helper.php” file is called and as a parameter, it receives the ID value of the category selected. In order to complete our search form then, we will need to complete the “helper.php” file by providing the following code:
# include all additional files
# retrieve Category ID from URL
# update child select menus
# helper function to automate child menu update
// erase all current (child) SELECT menu options
// add empty "Any" option to menu
# if a category has been specified
# run SQL query to return all child menu options
# outout a SELECT menu option for each row
# show all retrieved (child) SELECT
# add new option to child menu
} # END while results
} # END update_child_select()
Note: As before, we remove any spaces present in the field name before retrieving the HTML element object.
At this point, our page layout has been set up using HTML and CSS, our code flow has been defined, and our helper Search class has been initiated. Our application now has all of the logic necessary to intelligently create a search form for users to input their search criteria. What’s more, this logic is all easily reusable and requires little more than updating the logic found within our “inc.conf.php” (and possibly the “helper.php”) files.
This is a good start, as we have now laid the ground-work for part three of this article, which will cover retrieving a list of result records and sorting those records by each field specified. The real meat of the application lies there, but it is important to first establish an easily extensible interface with which users may conduct searches. So far we are right on track.
If you would like to see a working example of this application, you may do so here: http://portfolio.boynamedbri.com/devshed/search/part_2/. If you would like to download source code for this application, you may access that here: http://images.devshed.com/ds/stories/Creating_Searchable_Inventory_System/
blog comments powered by Disqus