1 / 10

Internet Applications

Internet Applications. Spring 2008. Review. Last week Open Source LAMP/Blog exercise Questions?. This week. Guest Speaker – David Walbert of LearnNC MySQL and PHP Exercises 6 & 7. Skills needed for exercises 6 & 7. Ex 6 – MySQL SQL syntax MySQL functions in PHP

Télécharger la présentation

Internet Applications

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Internet Applications Spring 2008

  2. Review • Last week • Open Source • LAMP/Blog exercise • Questions?

  3. This week • Guest Speaker – David Walbert of LearnNC • MySQL and PHP • Exercises 6 & 7

  4. Skills needed for exercises 6 & 7 • Ex 6 – MySQL • SQL syntax • MySQL functions in PHP • Ex 7 – Forms & form processing • Form coding and actions • Global variables • Page Logic

  5. MySQL • Open Source Relational Database • http://mysql.com • At SILS • pearl.ils.unc.edu • Relational database features • Tables, Indexes, Queries • SQL (Structured Query Language)

  6. SQL Skills • SQL – Structured query language • Uses a syntax with words like (select, where, insert, delete, from) to create logical statements • Select column from tablename where limit = ‘value’; • Insert into table (column, column) values (value 1, value 2); • A good reference • http://www.w3schools.com/sql/sql_quickref.asp

  7. SQL Examples • SELECT statements • SELECT * from feeds where username = 'mitcheet'", • SELECT * from feeds where id = ".$_REQUEST['feed'] • INSERT statements • INSERT INTO feeds (username, feedname, feedURL) values ('".$_REQUEST['username']."', '".$_REQUEST['feedName']."', '".$_REQUEST['feedUrl']."')"; • DELETE statements • DELETE from feeds where id = ".$_REQUEST['feedId']

  8. MySQL functions in PHP • Create a connection to the database • $connection = mysql_connect($dbserver, $username, $pass); • Select a database • mysql_select_db($database, $connection); • Run a query • $result = mysql_query("SELECT * from feeds where username = 'mitcheet'", $connection); • Get the results of the query as an array • while ($row = mysql_fetch_array($result, MYSQL_NUM)) {} • Close the connection • mysql_close($connection);

  9. MySQL Example function showFeed () { $connection = mysql_connect ("pearl.ils.unc.edu", "inls572_spring08", "yreuq572"); mysql_select_db("inls572_spring08", $connection); $result = mysql_query("SELECT * from feeds where id = ".$_REQUEST['feed'], $connection); while ($row = mysql_fetch_array($result, MYSQL_NUM)) { echo $row[3]; } }

  10. Next week • Wrap-up our exercises • More on JavaScript & Ajax • Cookies & maintaining page state • Class time to work on exercises or final project

More Related