Dreamweaver PHP Tutorial:
Recordset - A recordset is a set of information extracted from a
database by a database query.
Step 1: Create a Data Base
Create database called registration
Create a table called users with the following 6 felds:
Field Type leave at
default
Extra Primary
key int leae at
default
Auto!increm
ent
"es
frst archar #$%& leae at
default
last archar #'(& leae at
default
email archar #)(& *+,,
school archar #-(& leae at
default
class archar #-(& leae at
default
./en 0reamweaer
Step : De!ne t"e Site in Dreamweaver # Create a new
Conne$tion %etween Dreamweaver and &yS'(
Create a 121 /age
3ake sure the A//lications window is isible
Click on the 0atabases4543y67, connection
8ill in the info
Step ): Create *our Pages
Create t"an+you,p"p
-rite .T"an+ you for !lling out t"e form/ on t"is page,
./en - register./h/
0nsert Data 1%2e$ts3 4e$ord 0nsertion Form -i5ard
index./h/ results./h/
sorry./h/ thanksedit./h/
register./h/ search./h/
iew./h/ thanks./h/
Windows: No password
3acintosh: 1assword
is root
Select the data base
registration
Click on &enu Properties
"our fnished /age should look something like this:
9y/e registration in to/ row: design: style: etc. 3ake it /retty.
Add about $% records
Step 6: Create a Page to 7iew 8ll 4e$ords
./en iew./h/
Create a table with ' rows and % columns. ,abel it like this:
Select the
connection
Click on class and
select Menu
Type thanks.php
here
Delete the Key field
Add menu items by
clicking on the +
Make the abels and
!alues identical
Make the following
menu items:
&S -ord
&S Ex$el
&S PowerPoint
&S 8$$ess
;nsert a record set
*otice the sort and flter o/tions.
Click on the Bindings tab
0rag and dro/ the a//ro/riate binding into the corres/onding cell.
"our screen should look like this:
2ighlight the bottom row: click 9 and select 4epeat 4egion: make sure
you choose the correct recordset.
6ae and test it out.
Step ;: Count t"e <um%er of 4egistrants
./en iew./h/
;nsert a cell below the banner
Con"ention suggests
that all record sets
begin with #rs$
Sort by last name
Don%t include the key
field &for efficiency
purposes'
9y/e <um%er of 4egistrants:
Click on 9
and select
0is/lay
Record
Count40is/lay 9otal Records
6how <eginning record and end record.
8ormat it and test it.
Step =: Prote$t a Page wit" a >ser <ame and Password
?version @ onlyA
=o back to /h/3yAdmin
Add ' more felds
Call them username and password
Click on insert
Create a record with the username ralp" and the /assword wiggins
=o back to 0reamweaer
./en index./h/
Click in the center cell and create a table with - rows and ' columns
;n the left column: ty/e >ser <ame and Password
Click on 6erer <ehaiors 4 0ynamic <ehaior 4 ,og ;n +ser
Drag and drop first
a form and then te(t
fields from Forms
toolbar
Change field to password
format &all dots' by
clicking on the )roperties
toolbar
Select the correct
username column
Select the correct
password column
Step B: Create t"e 8%ility for >sers to Edit T"eir 4e$ords
./en search./h/
Create a record set that calls the feld last
Create a form with a menu and submit button
;t should look something like this
Click on the 3enu button
*otice #by looking at the 1ro/erties <ar& that it is called Sele$t
6elect the entire form
Choose an action #results./h/& and a method #=>9&
./en results./h/
Create a record set
Select register*php
Select sorry*php
Click on Dynamic and
select last
Set the filter to last
Set to URL Parameter
6elect ;nsert4A//lications .b?ect4+/date Record4Record +/date @iAard
9ell the /age to go to thanksedit./h/
Acce/t all the defaults
=o to the Bindings 9ab
Add a url /arameter for Sele$t
9he +R, ariable name is normally the name of the 293, form feld or
ob?ect used to obtain its alue.
Copy a re$ordset from one page to anot"er page
"ou can co/y a recordset from one /age to another within a defned site.
$. 6elect the recordset in either the <indings /anel or the 6erer <ehaiors /anel.
'. Right-click the recordset: and select Co/y from the /o/-u/ menu.
-. ./en the /age you want to co/y the recordset to.
). Right-click the <indings /anel or the 6erer <ehaiors toolbar: and select 1aste from the
/o/-u/ menu.
&a+e images dynami$
"ou can make images on your /age dynamic. 8or exam/le: su//ose you design a /age to dis/lay
items for sale at a charity auction. >ach /age would include descri/tie text and a /hoto of one
item. 9he /ageBs general layout would remain the same for each item: but the /hoto #and
descri/tie text& could change.
$. @ith the /age o/en in 0esign iew #Ciew 4 0esign&: /lace the insertion /oint where you
want the image to a//ear on the /age.
'. 6elect ;nsert 4 ;mage.
9he 6elect ;mage 6ource dialog box a//ears.
-. Click the 0ata 6ources o/tion #@indows& or the 0ata 6ource button #3acintosh&.
A list of content sources a//ears.
). 6elect a content source from the list: and click .D.
Set to Select &the name
of your menu+list on the
pre"ious page'
9he content source should be a recordset that contains the /aths to your image fles.
0e/ending on the fle structure of your site: the /aths can be absolute: document relatie:
or root relatie.
<ote: 0reamweaer does not currently su//ort binary images stored in a database.
;f no recordsets a//ear in the list: or if the aailable recordsets donBt meet your needs:
defne a new recordset.
Create a 4e$ordset:
$. >nter a name for the recordset: and select a connection.
'. 9he connection should be to a database containing data you want the user to search.
-. ;n the 9able /o/-u/ menu: select the table to be searched in the database.
). <ote: ;n a single-/arameter search: you can search for records in only a single table. 9o
search more than one table at a time: you must use the adanced Recordset dialog box and
defne a 67, query.
%. 9o include only some of the tableBs columns in the recordset: click 6elected and select the
desired columns by Control-clicking #@indows& or Command-clicking #3acintosh& them in
the list.
6. "ou should include only the columns containing information you want to dis/lay on the
results /age.
Create t"e re$ordset !lter:
$. 8rom the frst /o/-u/ menu in the 8ilter area: select a column in the database table in which
to search for a match.
8or exam/le: if the alue sent by the search /age is a city name: select the column in your
table that contains city names.
'. 8rom the /o/-u/ menu beside the frst menu: select the equal sign #it should be the
default&.
-. 8rom the third /o/-u/ menu: select 8orm Cariable if the form on your search /age uses the
1.69 method: or +R, 1arameter if it uses the =>9 method.
9he search /age uses either a form ariable or a +R, /arameter to /ass information to the
results /age.
). ;n the fourth box: enter the name of the form ob?ect that acce/ts the search /arameter on
the search /age.
9he name of the ob?ect doubles as the name of the form ariable or +R, /arameter. "ou can
get the name by switching to the search /age: clicking the form ob?ect on the form to select
it: and checking the ob?ectBs name in the 1ro/erty ins/ector.
8or exam/le: su//ose you want to create a recordset that includes only adenture tri/s to a
s/ecifc country. Assume you hae a column in the table called 9R;1,.CA9;.*. Also assume
the 293, form on your search /age uses the =>9 method and contains a menu ob?ect called
,ocation that dis/lays a list of countries. 9he following exam/le shows how your 8ilter
section should look: