Web Design

(Nancy Kaufman) #1

308


Search the Database ..............................................


4 Type <input type=”text”
name=”search”
id=”search” />.


5 Type <input
type=”submit”
value=”Search” />.


6 Type .


7 Save the page in the server’s
Web root.


1 In your editor, create a new
HTML document.


2 In the body, type <form
method=”post”
action=”?”>, replacing?
with the path to a PHP
document.


3 Type <label
for=”search”>
Search:.


Search the Database


P


roviding a search form is an effective way of allowing users to find the information they want
on your site. With your information stored in a database, enabling search on your page simply

involves creating a form for the user to type their search parameters, then using that data in a query


that displays the results of the search. Thus, searching involves simply combining the information


you have already gained in this chapter: creating and processing forms, running queries against the


database, and displaying the results. You need to add a filter, using the WHERE clause, to your SQL


statement to return only the records that match the search.


1


2


3


6


5


4

Free download pdf