Upload
mikeash82
View
220
Download
0
Embed Size (px)
Citation preview
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 1/30
Creating a Search page using PHP and MySQL
Creating a Search page using PHP and MySQL Michael Ashinze Page 1
Firstly, create your
database.
Create a database called
staff
And click create
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 2/30
Creating a Search page using PHP and MySQL
Creating a Search page using PHP and MySQL Michael Ashinze Page 2
Type in your table name
and Number of Fields
Here we will use details
and 5
And click Go
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 3/30
Creating a Search page using PHP and MySQL
Creating a Search page using PHP and MySQL Michael Ashinze Page 3
Enter the fields as shown
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 4/30
Creating a Search page using PHP and MySQL
Creating a Search page using PHP and MySQL Michael Ashinze Page 4
For the ID field
Select Primary
on the index
menu
and tick the A_I
field
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 5/30
Creating a Search page using PHP and MySQL
Creating a Search page using PHP and MySQL Michael Ashinze Page 5
Table has been
created
Click Insert to
add records
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 6/30
Creating a Search page using PHP and MySQL
Add the three more records below
First name Surname Course Email
Andy Quin Customer
Service
uk
Tracey Lee Network
Security
g.uk
John Smith Networking [email protected].
uk
Creating a Search page using PHP and MySQL Michael Ashinze Page 6
Enter records
and click on Go
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 7/30
Creating a Search page using PHP and MySQL
Creating a Search page using PHP and MySQL Michael Ashinze Page 7
Now you
should have 4
records in
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 8/30
Creating a Search page using PHP and MySQL
Creating a Search page using PHP and MySQL Michael Ashinze Page 8
Now we need
a website that
will allow usconnect to the
database with
a form.
Define a new
site
Click New
site
Now we need
a website that
will allow usconnect to the
database with
a form.
Now create a
new site with
the name
elattsearch
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 9/30
Creating a Search page using PHP and MySQL
Creating a Search page using PHP and MySQL Michael Ashinze Page 9
Select php
then
Select thehighlighted
layout
Click create
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 10/30
Creating a Search page using PHP and MySQL
Add some text to the main body
of the page as above and save the page as index.php. Now create
another page for your search results.
Creating a Search page using PHP and MySQL Michael Ashinze Page 10
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 11/30
Creating a Search page using PHP and MySQL
Add some text to the main body of the page asabove and save the page as searchresults.php
Creating a Search page using PHP and MySQL Michael Ashinze Page 11
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 12/30
Creating a Search page using PHP and MySQL
Creating a Search page using PHP and MySQL Michael Ashinze Page 12
Now on the index
page create a form
Go to
Insert > Form >
form
You should
now see a
selected area.
This is your
form area.
In the
properties
field, change
the method
form Post to
Get and link
the Action to
the
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 13/30
Creating a Search page using PHP and MySQL
Creating a Search page using PHP and MySQL Michael Ashinze Page 13
For Action:use the
browse icon to
navigate and
find the
searchresult
s.php page.
And for
Method select
Get from the
dropdown
menu.
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 14/30
Creating a Search page using PHP and MySQL
Creating a Search page using PHP and MySQL Michael Ashinze Page 14
Now create atext box for
your entry.
Insert >
Form > Text
box
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 15/30
Creating a Search page using PHP and MySQL
Creating a Search page using PHP and MySQL Michael Ashinze Page 15
Defining the
textbox
attributes:
ID: This is the
most important
field because
this is the field
that will be
connected to
your database.
It should be
given an easy
name that youcan remember.
Label: This is
just the name of
your text box. It
could be
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 16/30
Creating a Search page using PHP and MySQL
Creating a Search page using PHP and MySQL Michael Ashinze Page 16
Now your
form now has
a text box
with a title
First name.
This will allow
a user to type
the first name
of a staff they
require.
Now we will
create a
Button that
will be used to
submit the
search.
Go to:
Insert >
Form >
Button
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 17/30
Creating a Search page using PHP and MySQL
Creating a Search page using PHP and MySQL Michael Ashinze Page 17
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 18/30
Creating a Search page using PHP and MySQL
Creating a Search page using PHP and MySQL Michael Ashinze Page 18
Now just like the
text box we will
use the following
names
ID: find
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 19/30
Creating a Search page using PHP and MySQL
Creating a Search page using PHP and MySQL Michael Ashinze Page 19
The Button
has been
created with
but we can
change the
text to a more
appropriate
name. Like
Find
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 20/30
Creating a Search page using PHP and MySQL
Creating a Search page using PHP and MySQL Michael Ashinze Page 20
To do that,
click on the
submit button.
Then in the
properties
section,
change the
value to Find.
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 21/30
Creating a Search page using PHP and MySQL
Now you can save the index.php page.
Creating a Search page using PHP and MySQL Michael Ashinze Page 21
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 22/30
Creating a Search page using PHP and MySQL
Creating a Search page using PHP and MySQL Michael Ashinze Page 22
Now we will
connect the
website to our
mysql database.
On the
searchresult.ph
p page. Go to:
window >
Databases
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 23/30
Creating a Search page using PHP and MySQL
Creating a Search page using PHP and MySQL Michael Ashinze Page 23
In the database Panel,
Click the + sign and
select MySQL
Connection
Now Fill in the
connection form as
shown.
Make sure you use
the correct Password.
[This is your
phpmyadmin
password]
To choose the
database, click on
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 24/30
Creating a Search page using PHP and MySQL
Now click the test button to check that your connection is working.
If everything goes smoothly you should have this popup message. Click OK and
OK again
Creating a Search page using PHP and MySQL Michael Ashinze Page 24
Select the database
you wish to connect
to.
In this case we are
connecting to the
staff database.
Select staff and click
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 25/30
Creating a Search page using PHP and MySQL
Creating a Search page using PHP and MySQL Michael Ashinze Page 25
Now on the binding
Tab, Click on the +
sign then select
Recordset(query)
Your Record Set is
your query section.
Select a suitable
name for your
recordset. It could
be any name you
choose.
Here we will use:
Name: staffsearch
Filter: Select
Firstname [ This is
what you want the
user to type in the
form you have
created]
URL Parameter: first
name
[This must be the ID
name of the textbox
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 26/30
Creating a Search page using PHP and MySQL
Creating a Search page using PHP and MySQL Michael Ashinze Page 26
Now you should see
your record Set.
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 27/30
Creating a Search page using PHP and MySQL
Creating a Search page using PHP and MySQL Michael Ashinze Page 27
Now on the Data
section,
Select Dynamic
Data: Dynamic
Table
This allows you to
select the number of
records that at
displayed per page
Select your
preferences then
click ok
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 28/30
Creating a Search page using PHP and MySQL
Your results page is finally done. You can modify the table to suite your design.
Now you have finished creating the search page. We can now preview the site
from the index.php page.
Creating a Search page using PHP and MySQL Michael Ashinze Page 28
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 29/30
Creating a Search page using PHP and MySQL
In the preview page, Test the site by finding any name we have on the staff
database.
We will search for Michael; this is one of the names on the database. Type
Michael and click Find
Creating a Search page using PHP and MySQL Michael Ashinze Page 29
8/14/2019 Creating a Search Page
http://slidepdf.com/reader/full/creating-a-search-page 30/30
Creating a Search page using PHP and MySQL
Your result should show all the information you have about Michael.