17
1 Chapter 4 Chapter 4 Introduction to Databases Introduction to Databases in PHP in PHP

Dynamic Web Pages Ch 4 V1.0

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Dynamic Web Pages Ch 4 V1.0

1

Chapter 4Chapter 4Chapter 4Chapter 4

Introduction to Databases in Introduction to Databases in PHPPHP

Page 2: Dynamic Web Pages Ch 4 V1.0

2

Overview• In this chapter you will :

– Create a database connection in dreamweaver.

– Create a recordset.– Display data from the recordset.

Page 3: Dynamic Web Pages Ch 4 V1.0

3

Placing the database on the server

• We are going to using the database you created in the sql component: newlands.

• Make sure this is database is in the sql directory as shown below.

Page 4: Dynamic Web Pages Ch 4 V1.0

4

Exploring the Database• Open the database called

newland_tours.mdb.• This is the database that you will

be working with.• The relationships look like this.

Page 5: Dynamic Web Pages Ch 4 V1.0

5

Connecting the site to a database

• Select the + as shown.• The following sql

connection appears, select it.

• This will produce a dialog as shown.

Note the database tag has been selected.

Complete the dialog as shown.Test the connection and click OK

Page 6: Dynamic Web Pages Ch 4 V1.0

6

Check the Connection• Click on the + and explore

the tables etc.

• Note a folder has been added to your site with the connection php file.

• This file is a Dreamweaver configuration.

Page 7: Dynamic Web Pages Ch 4 V1.0

7

What’s in the connection file?

Page 8: Dynamic Web Pages Ch 4 V1.0

8

Displaying data Using a recordset- 1

• Open the index.php file in design view and delete the highlight text.

Page 9: Dynamic Web Pages Ch 4 V1.0

9

Displaying data - 2• Select the traveller’s journal image and right

click on the h3 tag in the tag selector.• Select the remove tag from the pop up

menu.

Page 10: Dynamic Web Pages Ch 4 V1.0

10

Displaying data - 3• Select

the + in the bindings as shown.

• Fill in the dialog as shown.

Creating a recordset

Page 11: Dynamic Web Pages Ch 4 V1.0

11

Displaying data - 4• Drag and drop

description as shown.

• Looks like• You can also view

Data using the live data as shown

Page 12: Dynamic Web Pages Ch 4 V1.0

12

Lab 4 -1• Overview

– Create sql connection for the lab database

– Create a dreamweaver connection– Create a recordset for the equipment.– Create a dynamic table using the

equipment recordset.

Page 13: Dynamic Web Pages Ch 4 V1.0

13

Lab 4 equpment.php Design

Dynamic table

Page 14: Dynamic Web Pages Ch 4 V1.0

14

Lab 4 equipment.php live

Page 15: Dynamic Web Pages Ch 4 V1.0

15

Lab 4 -2• Connect the site to the database

– call it dwda.

• Open equipment.php page.• Create a recordset

– Call it rs_equip– Select all field except EquipID– Sort on EquipType field in Ascending order.

• Test the recordset.

Page 16: Dynamic Web Pages Ch 4 V1.0

16

Lab 4- recordset

Page 17: Dynamic Web Pages Ch 4 V1.0

17

Lab 4 -3• Select the HTML table containing equipment

and delete the table. • On the Application tab on the Insert bar, click

Dynamic Data and choose Dynamic Table. • Choose all records from the rs_equip recordset

and give a border of 1 and a cellpadding of 3. • Click OK. • Change the headings to be more descriptive

and bold them. • Save the page and preview it.