.


:




:

































 

 

 

 


. , , if.

 

, ( ). , PHP.

.

Run.exe, : C:\Webserver\Denwer. Apache Z: . 1.1.

 

. 1.1. .

 

php WWW. , prog 1. php, - http://localhost/prog1.php ( - , - http:// localhost:8888/)

.

 

1

. PHP, , .

 

1. .1-.3.

2. ( lab1_1.php),

($product1, $product2, $product3) ($priec1, $priec2, $priec3), .

.

.1.2.

. 1.2. lab1_1.php.

 

2.1. .

. , printf(). ,

printf("<h3 align=center> %.2f .</h3><br>",$sr);

, . %.2f . .

3. . , .1.3.

. 1.3.

 

3.1. (echo print). , :
echo "< tr >< td >$ tov 1</ td >< td >$ price 1</ td ></ tr >";

lab1_21.php

3.2. HTML . . , HTML :
<tr>< td ><?echo $tov1;?></ td >< td ><?=$ price 1?></ td ></ tr >

: <? = $ tov 1?>

lab1_22.php

 

2

. PHP, .

 

1. . (. 2.1).

. 2.1. lab2_1.php.

 

1.1. , if elseif.

lab2_1.php, 1. . , $max_prise, $max_ product, .

( elseif else) . .

1.2. .

. , "", if.

2.1. lab2_1.php lab2_2.php .

$max_prise $max_ product . , $max_prise ( if). , $max_prise $max_ product.

2.2. .

2.3. .

 

3

. PHP. .

 

 

1. (. 4). .

2. 2 , . : - , . . . lab3_1.php

3. lab3_2.php, .

3.1. (. 4.2).

3.2. , , , .

3.3. : " " " ".

3.4. .

4. , . , control($p), :

 

print control("1234");

 

return.

4

. while for. .

 

1. . 3, PHP. 3.4 3.5.

2. .

100 . .

10%.

3,5% .

. , 150 .

while. lab4_1.php. .

for.

5 . => .

( lab 4_2.php) .

3. lab 4_2.php ( lab 4_3.php) .

170 , 3,5%. 10 .

 

5

 

. () .

.

 

 

1. . 5 .

2. , ( lab5_1.php).

( ), 5- array() (. 5.1).

(. 5.2).

, count (), for.

3. .

3.1. , ( sort). .

4.
lab 4_2.php.

4.1. .

: => . () , .

5- , array(), (. 5.4 5.5).

, foreach() (. 5.8).

, .

5. .

.

6. :

6.1. () ( asort()/arsort()).

6.2. , ksort()/krsort()

7. .

6

. . , .

 

1. . 6. 6.1 6.4.

2. , .

2.1. html- ( lab6_1.html), ..., , Email, php- - lab6_2.php .

2.2.

2.3. , lab6_3.php. . .

3. 6.5 6.6 .

4. , . . lab6_4.php .

5. , , .

6. lab6_5.html . , 4 :

(text) to

(text) subject

(textarea) message

(submit) mail_ok

POST (lab5_5.php) .

.

, : $to, $subject $message (. . 3.1).

e-mail, $mail.

mail ():

 

bool mail (string $to, string $subject, string $message)

 

TRUE FALSE . If .

. 6.1. .

7. .

7

. .

 

1. . 7.

2. , .

3. - ( lab7_1.php).

3.1. radio-button (. . 7.1).

 

. 7.1. .

 

:

, , , . .

.

1. : 5.txt, 4.txt, 3.txt 2.txt 0 . .

2. , . (5, 4, 3, 2), . :
<input type="radio" name="vote" value="5" checked > <br>

3. (, POST). ( ):

if (@$_POST['vote']) {

// vote post,

$file=$_POST['vote'].".txt";

// vote 2, 3, 4, 5. ,

$f=@fopen($file,"r");

//

$votes=fread($f,100);

// $votes

fclose($f);

//

$votes++;

//

$f=@fopen($file,"w");

//

fwrite($f,$votes);

//

fclose($f);

//

4. ( . . 7.2).

. 6.2. .

5. , 1.txt 5.txt.

6. ** , (. . 7.3).

. 6.3. .

 

:

<hr> . :

?>

<hr align="left" color="#FF0000" size="20"

<?

, , php- - . -.$v1[$i].

() .

==

** - .

7. . 2.txt, 3.txt,4.txt, 5.txt 0. - . .

8

. .

 

1. . 8. 8.1 .

2. : - (, 1. 04. 2005), , . lab8_1.php.

3. , . . lab8_2.php.

4. lab8_3.php, .

, :

" (-) ".

.

.

. $weekday=date('D');

$weekday (Mon, Tue, Wed, Thu, Fri, Sat, Sun). $weekday.

if ($weekday = = 'Mon') { $weekday=""};

..

5. .

9

. . .

 

1. . 9, printf().

2. , .

3. ( lab9_1.php), - . , 2- .

:


- 140.00 = 4.23 $ = 3.47
- 181.00 = 6.39 $ = 5.24
- 134.00 = 4.73 $ = 3.88

3.1. .

.

.

foreach(), .

3.2. . , . .

4. .10. . 10.1 10.5.

5. , ( lab9_2.php),.

5.1. .

"!".

- @, , .

. , " @!". " !"

5.2. .

6. , e - mail, . , " : mail. ru ".

7. .

10

. PHP MySQL. , , .

 

1. . 11, .

mysql_connect(" ", " ",""),

mysql_select_db(" "),

create table ( )

2. Denwer , .

2.1. http://localhost, http://localhost /Tools /phpMyAdmin. MySQL.

2.2. , , baza1, .

. 9.1.

MySQL, SQL-, PHP-.

3. 11.2 PHP. localhost, root, . ,
$p = mysql_connect(" ", " ","") :

$p = mysql_connect("localhost", "root","");

:

mysql_select_db("baza1") or die("NO BASE");

4. .

4.1. .11 . telephones (. 11.3):
create table telephones(id INT AUTO_INCREMENT PRIMARY KEY,

surname VARCHAR(20),

email VARCHAR(20),

tel VARCHAR(20));

4.2. telephones . .

4.3. , . .

5. PHP.

5.1. 11.3.

5.2. phpMyAdmin. telephones..

5.3. PHP (. 11.4).

6. . 11.5, 11.6. , .

7. .

7.1. 11.7 11.8.

8. products ( - , , , ) ( ). .

 

( ) :

mysql_query("insert into products( ) values()").

 

( ).

 

.

11

. PHP . . ( products 10).

 

1. - . , country,

id _ c ,

name _ c .

. . 8.1.

 

. 10.1. country .

 

2. . , . 10.2.

. 10.2. country .

 

3. products - . id _ c country (. . 10.3).

. 10.3. products country.



<== | ==>
| 
:


: 2018-10-18; !; : 1038 |


:

:

,
==> ...

1693 - | 1571 -


© 2015-2024 lektsii.org - -

: 0.123 .