Presentation is loading. Please wait.

Presentation is loading. Please wait.

MySQL. Is a SQL (Structured Query Language) database server. Can be accessed using PHP with embedded SQL Queries Supports Large DB’s, 60,000 tables with.

Similar presentations


Presentation on theme: "MySQL. Is a SQL (Structured Query Language) database server. Can be accessed using PHP with embedded SQL Queries Supports Large DB’s, 60,000 tables with."— Presentation transcript:

1 MySQL

2 Is a SQL (Structured Query Language) database server. Can be accessed using PHP with embedded SQL Queries Supports Large DB’s, 60,000 tables with about 5,000,000,000 rows http://www.mysql.com

3 MySQL & PHP Connecting To A DB Usually Store in Connect.INC mysql_connect("localhost","cs3ai01","saUrZnPP") OR die("Could Not Connect to Database"); mysql_select_db("cs3ai01") or die("Failed Selecting to DB"); DB HOST Username Password Database Name

4 MySQL & PHP Querying A DB After Connecting $query = "SELECT Name, Colour, Fabric, Engine_Size, Cost, FROM Products WHERE Type = 'Motorcycle'"; $result = mysql_query($query); SQL Query Tag Select Variables DB Name Where Clause Saves Data Received in result

5 MySQL & PHP Insert into Database $query = "INSERT INTO StudentMarks (StudentID,Mark,SubjectCode,Component) VALUES (“98551566”,”80”,”CSE32MS”,”Assignment”)"; $result = mysql_query($query); SQL Query TagInsert DB Tag DB Value ID’s DB Value TagInsert Values Db Name

6 MySQL & PHP Deleting From The DB $query = "DELETE FROM StudentMarks WHERE StudentID = '$student_number' AND SubjectCode = '$subject' AND Component = '$component'"; $result = mysql_query($query); SQL Query TagDelete DB Tag Db Name

7 MySQL & PHP Updating Values In DB $query = "UPDATE StudentMarks SET Mark = $Mark WHERE Component = '$component' AND StudentID = $student_number AND SubjectCode = '$subject'"; $result = mysql_query($query); SQL Query TagUpdate DB Tag Db Name DB Set Where Clause New Value

8 MySQL & PHP Displaying Retrieved Data Product Name Colour Fabric Engine Size Cost Site <?php while( $row = mysql_fetch_array($result) ) { ?> <?php echo $row["Name"]; ?>

9 MySQL & PHP Combination Of HTML, PHP & Mysql > HTML Tag PHP Tag Retrieved DB Info

10 PHP, MySQL & An Image DB <?php include("../connect.inc"); $query = "SELECT Colour,Image_Name FROM Images WHERE Type = 'Car' AND Colour = 'Black'"; $result = mysql_query($query); ?> <?php if( mysql_num_rows($result) < 1) { include("error.htm"); die(); } ?> <?php while( $row = mysql_fetch_array($result) ) { ?> <img border="0" src= > <?php } ?>

11 Class Example <?php if( $component == "" ) { include("empty-component-error.php"); die(); } else { include("connect.inc"); $query = "SELECT Component FROM StudentMarks WHERE Component = ‘$component’ AND SubjectCode = “CSE32MS” AND StudentID = “98551566”"; $result = mysql_query($query); if( mysql_num_rows($result) < 1 ) { $component_found = FALSE; include("no-component-error.php"); } ?>

12 Class Example <?php $username = “John”; $FirstName = “John”; $Surname = “Little”; $Access = “Administrator”; $password = “Monday”; $query = "INSERT INTO Users (LoginName,FirstName,Surname,Password,Access) VALUES ('$username','$password','$firstname','$password', '$access')"; $res= mysql_query($query); echo mysql_error(); include("complete-contents.htm");} ?>

13 References: On the ICC Web Page there are a PHP and MySQL manuals in the form of a help files and so that you can easily refer to them. http://students.cs.latrobe.edu.au/../icc


Download ppt "MySQL. Is a SQL (Structured Query Language) database server. Can be accessed using PHP with embedded SQL Queries Supports Large DB’s, 60,000 tables with."

Similar presentations


Ads by Google