You are on page 1of 30

SynapseIndia Feedback on PHP

and MySQL Web DevelopmentPart 5

PHP and MySQL Web


Development

Update data from a form into a database:


Now we will create an HTML form that can be used

to update one column in the Friend table, file


update1.php. We have arbitrarily chosen to
update the first name of the person.
The first test: has the user submitted the form?
Second test: is there something in every field?
Third test: is the new first name longer than the
field domain permits?

PHP and MySQL Web


Development

PHP and MySQL Web


Development

PHP and MySQL Web


Development

PHP and MySQL Web


Development

PHP and MySQL Web


Development

PHP and MySQL Web


Development

PHP and MySQL Web


Development

Lets find out what there is in the table Friend:

10

PHP and MySQL Web


Development

11

PHP and MySQL Web


Development

The task is to update the first name Rosalind to

Rosalind Elsie:

12

PHP and MySQL Web


Development

13

PHP and MySQL Web


Development

14

PHP and MySQL Web


Development

The third test: has the user inputted too long a

name?:

15

PHP and MySQL Web


Development

New First Name: Longer than 45 character constants

16

PHP and MySQL Web


Development

17

PHP and MySQL Web


Development

One more detail from the previous example: the

first parameter of the mysql_query() is UPDATE


statement.
UPDATE and DELETE statements behave in the
same way in those kinds of situations: if there are
no rows to be updated or deleted, then there
would not come any warnings or errors back:

18

PHP and MySQL Web


Development

19

PHP and MySQL Web


Development

20

PHP and MySQL Web


Development

Definitely we need to improve the source code:

21

PHP and MySQL Web


Development

22

PHP and MySQL Web


Development

23

PHP and MySQL Web


Development

Let us test the modification. The second name and

the address are valid values:

24

PHP and MySQL Web


Development

25

PHP and MySQL Web


Development

26

PHP and MySQL Web


Development

The following example selects the same data as

the example above, but will display the data in an


HTML table:

27

PHP and MySQL Web


Development

28

PHP and MySQL Web


Development

29

PHP and MySQL Web


Development

30

PHP and MySQL Web


Development

You might also like