Presentation is loading. Please wait.

Presentation is loading. Please wait.

Objectives  Create a database using Mysql  Create a tables and insert data on them  Create a relationship between tables  Create a user  Export your.

Similar presentations


Presentation on theme: "Objectives  Create a database using Mysql  Create a tables and insert data on them  Create a relationship between tables  Create a user  Export your."— Presentation transcript:

1 Objectives  Create a database using Mysql  Create a tables and insert data on them  Create a relationship between tables  Create a user  Export your database to a text file  Print & echo variables  Arrays  Using different types of loops  PHP Forms & field validation  Insert a record to mysql database using php form  Update a record in mysql database using php file  Update a record in mysql database using php form  Select everything from mysql database table

2 Activity Outcomes ■The student should know how to Create a database using Mysql in phpmyadmin ■The student should know how to Create tables and insert data on them ■The student should know how to Create relations between tables ■The student should know how to Export your database to a text file ■The student should know how to print in php ■The student should know how to use & manipulate arrays in php ■The student should know how to use loops in php ■The student should know how to use form and field validation in php ■The student should know how to Insert a record to mysql database using php form ■The student should know how to Update a record in mysql database using php file ■The student should know how to Update a record in mysql database using php form ■The student should know how to Select everything from mysql database table

3 PHPADMIN TABLE

4 أولا : تشغيل السيرفر ثانيا : الذهاب للمتصفح وكتابة العنوان التالي :http://localhost/phpmyadmin/

5  Create a database using Mysql Run the wamp server Open the web browser and write on the address bar http://localhost. The wamp web page will open go to phpmyadminphpmyadmin Create a new database called AZcompany

6  Create an Employees table and insert data on it كتابه اسم الجدول وتحديد عدد العواميد ☺

7 بعد تحدي الاسم وأعمدة الجدول يضاف الجدول في قاعده البيانات كما في الشكل. ولتعبئه البيانات من أدوات الجدول « ادخال » بعدها تظهر صفحه الادخال ويتم ادخال البيانات

8 Field nameType Emp-IdVarchar(20) first-nameVarchar(100) last-nameVarchar(100) AgeInt 1)Create a table called Employees containing 4 fields as follows: Emp-Id (primary key)first-nameLast-nameAge 10AhmadAli30 20MohammadSaeed45 30SameerSaleh35 2)Insert the following data in the Employees table

9 1)Now create 2 more tables: -Department table (Primary-Key(Dept-Id), name) -Emp-Info table (Primary-Key (Emp-Id, Dept-Id), startDate) Dept-Idname 101Accounting 102Sales 103Finance 104Marketing  Fill the Department table with the following data:

10  Create a user  Create a user called admin1 and give it all the privileges  Export your data base to a text file 1.Select your data base 2.Export the data base as SQl format and copy the statements to a text file name mydb.sql

11 privilege من امتيازات / تتم اضافه مستخدم وتحديد صلاحياته يتم استخدام أداة تصدير لإخراج البيانات الى الجهاز ومن ثم حذف الجدول الذي تم تصديره واعادة استيراده من الاداة استيراد

12 PHP

13 يجب حفظه بالامتداد الظاهر بالشكل في القرص الصلب في مجلد السيرفر php ليتم تشغيل أو عرض ملف 1 2 3

14 <?php $name = "Ahmad"; // declaration and initialization ?> Simple PHP document "; ?> Welcome to PHP, !  Print & Echo variable In PHP there are two basic ways to get output: echo and print. 1.Open the notepad 2.Write the following code 3.save the file as welcome.php in the wamp\www directory 4.open the browser write the following in the address bar (http://localhost/welcome.php)http://localhost/welcome.php

15 Array manipulation <?php $brush_price = 5; echo " "; echo " Quantity "; echo " Price "; for ( $counter = 10; $counter "; echo $counter; echo " "; echo $brush_price * $counter; echo " "; } echo " "; ?>  Arrays Different ways of declaration and using loops for manipulation:

16  Using different types of loops with php: For loop with phpWhile loop with php Do..while loop with phpForeach loop with php

17 Name : E-mail: Welcome Your email address is:  PHP Forms First we create an html file that contains a form, the action = a php file: -Now we create the welcome.php file as follows:

18 PHP WITH DATABASE

19 Emp-Id: First-name: Last-name: Age:  Insert into mysql database We want to make a connection between a form and mysql database, so we can insert the values from the form directly into database. 1.First, create an html form and save the file as insertform.html

20 2. Second, create a php file and save it as insert.php as the following: <?php $con= mysqli_connect("localhost","root","","AZcompany"); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: ". mysqli_connect_error(); } $sql="INSERT INTO Employees VALUES ('$_POST[id]','$_POST[firstname]','$_POST[lastname]','$_POST[age]')"; if (!mysqli_query($con,$sql)) { die('Error: '. mysqli_error($con)); } echo "1 record added"; mysqli_close($con); ?>

21 <?php $con=mysqli_connect("localhost","root","","AZcompany"); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: ". mysqli_connect_error(); } mysqli_query($con,"UPDATE Employees SET Age=36 WHERE Emp_Id='10' "); mysqli_close($con); ?>  Update a record in mysql database: Create a php file to update the record directly with known values:

22 CONNECTION BETWEEN PHP FORM “SELF STUDY”


Download ppt "Objectives  Create a database using Mysql  Create a tables and insert data on them  Create a relationship between tables  Create a user  Export your."

Similar presentations


Ads by Google