1 / 5

Intro to PHP and MySQL

Intro to PHP and MySQL. ICS 215 Jan Stelovsky. PHP History. Rasmus Lerdorf 1995 Not an academic, consultant Goal dynamic web sites not doing the same thing over and over Solution Reusable code snippets HTML Templates. PHP Facts. Installed on 2.1 million web servers

arion
Download Presentation

Intro to PHP and MySQL

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. Intro to PHP and MySQL ICS 215 Jan Stelovsky

  2. PHP History • Rasmus Lerdorf 1995 • Not an academic, consultant • Goal • dynamic web sites • not doing the same thing over and over • Solution • Reusable code snippets • HTML Templates

  3. PHP Facts • Installed on 2.1 million web servers • Used on 244 million websites • deployed on most web servers • as standalone shell on almost every operating system • Usage • server-side scripting language • also general-purpose programming language • web development • interpreted by a web server • PHP processor generates web page • PHP commands embedded directly in HTML source • similar to Ruby on Rails, • free • PHP License, like GNU General Public License (GPL)

  4. Taste of PHP and MySQL <?php $dsn = 'mysql:host=localhost;dbname=app'; $user = 'root'; $password = 'secret'; $query = "SELECT vendor_name, invoice_no, invoice_tot FROM vendors INNER JOIN invoices ON vendors.vendor_id = invoices.vendor_id WHERE invoice_tot>= 500 ORDER BY vendor_name, invoice_totDESC"; try { $database = new PDO($dsn, $user, $password); } catch (PDOException $error) { echo $error->getMessage(); exit(); } $rows = $database->query($query); ?>

  5. Taste of PHP and MySQL (cont) <!DOCTYPE html> <html lang="en"><head> <title>PHP & MySql Test</title> </head><body> <h1>Invoices with totals over 500:</h1> <?phpforeach ($rows as $row) : ?> <p> Vendor: <?php echo $row['vendor_name']; ?><br/> Invoice#: <?php echo $row['invoice_no']; ?><br/> Total: $<?php echo number_format($row['invoice_tot'], 2); ?> </p> <?phpendforeach; ?> </body></html>

More Related