Вы находитесь на странице: 1из 10

PHP MySQL

PHP MySQL

SQL ()
SQL (. Structured Query Language )
, ,

SQL :

(Data Definition Language, DDL)

(Data Manipulation Language, DML)

(Data Control Language,


DCL)

http://ru.wikipedia.org/wiki/SQL

PHP MySQL

SQL. SELECT
SELECT name, addr, city
FROM teachers
ORDER BY name
SELECT title
FROM courses
WHERE length > 30
SELECT *
FROM courses
WHERE length > 30
AND title LIKE Web%

PHP MySQL

SQL. INSERT
INSERT INTO courses (title, length)
VALUES (Java2, 40)

PHP MySQL

SQL. DELETE
DELETE FROM lessons
WHERE lesson.date = 2005-06-11

PHP MySQL

SQL. UPDATE
UPDATE teachers
SET
zarplata = zarplata * 2,
premia = premia * 10
WHERE name LIKE %
OR name LIKE %
OR name LIKE %
UPDATE teachers
SET
zarplata = zarplata * 2,
premia = premia * 10
WHERE name IN
(, , )

PHP MySQL

MySQL
mysql_connect
mysql_select_db
mysql_query
mysql_num_rows

mysql_num_fields

mysql_errno
mysql_error
mysql_fetch_array
mysql_fetch_assoc
mysql_fetch_row
mysql_close

MySQL


,

MySQL
MySQL



PHP MySQL
MySQL.

<?php

?>

// MySQL-
@$con = mysql_connect('localhost', 'vasya', 'superpass')
or die (" ".mysql_errno().": ".mysql_error()."<br>");
//
@mysql_select_db('vasya',$con)
or die (" ".mysql_errno().": ".mysql_error()."<br>");
//
$query = 'SELECT * FROM vasya_table';
@$result = mysql_query($query,$con)
or die (" ".mysql_errno().": ".mysql_error()."<br>");
//
while($row = mysql_fetch_array($result)){
echo $row['id']." ".$row['field']."<br>";
}
//
@mysql_close($con);

PHP MySQL

PHP MySQL


1. SQL- users
:
id INT AUTO_INCREMENT PRIMARY KEY,
user VARCHAR(32),
password VARCHAR(32).
2. - .
.
HTML- .

Оценить