Подключение базы данных из PHP файла

Лабораторная работа

Информатика, кибернетика и программирование

Цель: Научиться подключать Базы данных вручную и при помощи SQL. Подключение к базе данных mysql_connect loclhost dmin dmin ; подключение к серверу MySQL mysql_crete_db students ; создание базы данных mysql_select_db dmin ; подключение к базе данных dmin 2.Передать системе управления базой данных SQLзапрос с инструкцией mysql_query CRETE TBLE STnumber INTNme TEXT ; создание таблицы ST mysql_query INSERT INTO stnumber Nme VLUES'1''IVN' ; внесение данных в базу 3.



24.5 KB

10 чел.

Лабораторная работа 69 

Тема: Подключение базы данных из PHP файла .

Цель: Научиться подключать Базы данных вручную и при помощи SQL.

Теоритический материал

1.Подключение к базе данных

mysql_connect("localhost","admin","admin");//подключение к серверу MySQL

mysql_create_db("students");//создание базы данных

mysql_select_db("admin");//подключение к базе данных admin

2.Передать системе управления базой данных SQL-запрос с инструкцией

mysql_query("CREATE TABLE ST(number INT,Name TEXT)");//создание таблицы ST

mysql_query("INSERT INTO st(number, Name) VALUES('1','IVAN')");//внесение данных в базу

3.Получить и обработать данные.

$row=mysql_fetch_array($result);//результат выполнения SQL-запроса сохранялись в переменной //$result

4.Закрыть соединение с базой данных.



А также другие работы, которые могут Вас заинтересовать

57676. Їжа та напої 1.04 MB
  Of course,you are right! Our mood depends on our meals. As you guessed, The topic of our today lesson is Food and Drinks. We will speak, read, listen, write about food and drinks during our lesson.
57677. Healthy way of life. What does it mean to ве healthy? 89.5 KB
  You see the Sun on the blackboard, it’s our health. What is health for you? What do you associate with health? And the first task is “Associations”. Write your associations with the word “Health” on these stripes-sunrays and stick to our Sun.
57678. In sound body - sound mind 129.5 KB
  Good health is a great gift. The English proverb says, «Health is not valued till illness comes». The most important thing in the world is our health. Each person is a creator of the human body. Now look at the blackboard. Here you see the main words of the proverb.
57679. Veterans Day 188.5 KB
  Veterans Day is observed with ceremonies at war monuments and cemeteries throughout the nation. Almost every village has a monument to veterans who served in one of the country’s wars.
57680. ЗІРКИ МУЗИКИ 108.5 KB
  It’s true because we can’t imagine our life without music. People all over the world are fond of music. They listen to music, they dance to music, they learn to play musical instruments. People make their own music too.
57681. The Beauty of Future Cities 40.5 KB
  Show the students some photos of the future cities. It can be initial slides of your power point presentation and ask them to guess what the theme of the lesson is. Right you are. Today we are going to have a talk about megacities of today and their future.
57682. Books are Our Friends. The World of Books 44.5 KB
  Objectives: Pupils’ learning outcomes: practical to present and give practice in the use of new words; will learn 8 new words; to present and give practice in the use of “be fond of”, will be able to express their attitude to reading and “be interested in” in the micro dialogues...
57683. Великобританія 59 KB
  So, we have refreshed our knowledge about our topic and it’s time for you to represent your own information about traditions in Great Britain. It was your home task for today.
57684. Favourite Clothes 116 KB
  Materials: a student book, pictures of clothes, cards with the names of clothes, cards with the task for reading, cards for practicing the phrasal verbs, pictures of three persons and cut sentences with their descriptions.