PHP with MYSQL Please use speaker notes for additional information!

Slides:



Advertisements
Similar presentations
PHP SQL. Connection code:- mysql_connect("server", "username", "password"); Connect to the Database Server with the authorised user and password. Eg $connect.
Advertisements

PL/SQL User Defined Types Record and Table Please use speaker notes for additional information!
Group functions using SQL Additional information in speaker notes!
Relational example using donor, donation and drive tables For additional information see the speaker notes!
More on IF statements Use speaker notes for additional information!
Faculty of Sciences and Social Sciences HOPE PHP & MySQL Stewart Blakeway FML 213
PHP and MySQL PHP for the Web, page PHP and MySQL MySQL Resource PHP – MySQL Resource
MySQL and PHP By Trevor Adams.
ADVM420- Class #4 Web Design with PHP and MySQL Adding and Listing from a MySQL Database.
1 CS428 Web Engineering Lecture 23 MySQL Basics (PHP - VI)
SQL Use of Functions Character functions Please use speaker notes for additional information!
SQL | PHP Tutorial at 8am. god, it’s early.. SQL intro There are many different versions of SQL available for usage. Oracle MySQL SQLite DB2 Mimer The.
What is MySQL? MySQL is a database. The data in MySQL is stored in database objects called tables. A table is a collections of related data entries and.
Deleting and Updating Records in MySQL using PHP Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
© Yanbu University College YANBU UNIVERSITY COLLEGE Management Science Department © Yanbu University College Module 6:WEB SERVER AND SERVER SIDE SCRPTING,
Cursors in PL/SQL Includes cursor example and continuation of first cursor example Please use speaker notes for additional information!
Class 3 MySQL Robert Mudge Reference:
MySQL in PHP – Page 1 of 17CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: MySQL in PHP Reading: Williams &
PC SHOP by: Hussein Zahr ECE 3553: Multifarious Final Project.
PHP – MySQL Extensions. Table used in most examples CREATE TABLE product ( rowID INT NOT NULL AUTO_INCREMENT, productid VARCHAR(8) NOT NULL, name VARCHAR(25)
INTERNET APPLICATION DEVELOPMENT PRACTICAL ON CONNECTING TO MYSQL.
Mark Dixon Page 1 23 – Web applications: Writing data to Databases using PhP.
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
PHP MySQL Introduction. MySQL is the most popular open-source database system. What is MySQL? MySQL is a database. The data in MySQL is stored in database.
PHP MySQL. SQL: Tables CREATE TABLE tablename { fieldname type(length) extra info,... } Extra info: –NULL (allows nulls in this field) –Not NULL (null.
Polling System Part 1 Creating PHP & MySQL Files CIS 254.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
PHP Part 2.
INTERNET APPLICATION DEVELOPMENT Practical on Sessions.
1. Connecting database from PHP 2. Sending query 3. Fetching data 4. Persistent connections 5. Best practices.
Lecture 10 – MYSQL and PHP (Part 2)
Relationships and Advanced Query Concepts Using Multiple Tables Please use speaker notes for additional information!
Database Access with PHP and MySQL CS356 Examples from Web Database Applications, by Hugh E. Williams & David Lane, O'Reilly, 2002.
PHP with MySQL 1.
PHP+MySQL Integration. Connecting to databases One of the most common tasks when working with dynamic webpages is connecting to a database which holds.
XML and DTD Please you speaker notes for additional information!
MySQL Database Connection
CISC 3140 (CIS 20.2) Design & Implementation of Software Application II Instructor : M. Meyer Address: Course Page:
Intro to DatabasesClass 4 SQL REVIEW To talk to the database, you have to use SQL SQL is used by many databases, not just MySQL. SQL stands for Structured.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP & MySQL.
SQL and Conditions Speaker notes will provide additional information!
2010/11 : [1]PHP with MySQLBuilding Web Applications using MySQL and PHP (W1) PHP with MySQL.
PHP Database connectivity Connecting with RDBMS and editing, adding, and deleting databases therein are all done through PHP functions.
Exceptions in PL/SQL Please use speaker notes for additional information!
Controlling Web Site Access Using Logins CS 320. Basic Approach HTML form a php page that collects the username and password  Sends them to second PHP.
Introduction to Oracle - SQL Additional information is available in speaker notes!
ASP.NET Binding and an Introduction to Database Queries Please use speaker notes for additional information!
PHP getting data from a MySQL database. Replacing XML as data source with MySQL Previously we obtained the data about the training session from an XML.
NMD202 Web Scripting Week5. What we will cover today PHP & MySQL Displaying Dynamic Pages Exercises Modifying Data PHP Exercises Assignment 1.
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.
Chapter 8 Manipulating MySQL Databases with PHP PHP Programming with MySQL 2 nd Edition.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Using a Database Access97 Please use speaker notes for additional information!
OBJECTIVES Learn how to view data using SQL and PHP Learn how to add new data using SQL and PHP PHP+SQL: View and Adding,
Tried my best to simplify it for you!
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Storing Images Connect to the server using the correct username and password. $conn = mysql_connect(“yourserver”, “joeuser”, “yourpass”); Create the database.
Database application MySQL Database and PhpMyAdmin
Introduction to Web programming
MySQL - Creating donorof database offline
Please see speaker notes for additional information!
PHP: Combo box FdSc Module 109 Server side scripting and
Web Programming– UFCFB Lecture
PHP AND MYSQL.
Updating Databases With Open SQL
Database Access with PHP and MySQL
Introduction to Web programming
Updating Databases With Open SQL
Presentation transcript:

PHP with MYSQL Please use speaker notes for additional information!

<?php $link = mysql_connect("mysql2.nevidia.com", "pgrocer.biz", "password") or die("Could not connect: ". mysql_error()); print ("Connected successfully"); mysql_close($link); ?>

<?php $link = mysql_connect("mysql2.nevidia.com", "pgrocer.biz", "password", "pgrocer_biz_data") or die("Could not connect: ". mysql_error()); print ("Connected successfully"); mysql_select_db("pgrocer_biz_data"); $result idno from donor") or die("Invalid query: ". mysql_error()); while ( $row = mysql_fetch_row($result)) { echo (" ". $row[0]. " "); } ?> My database as assigned by Nevidia. My table. I am now looping through the table showing one row at a time starting the index at 0.

<?php $link = mysql_connect("mysql2.nevidia.com", "pgrocer.biz", ”password", "pgrocer_biz_data") or die("Could not connect: ". mysql_error()); print ("Connected successfully"); mysql_select_db("pgrocer_biz_data"); $result idno from donor") or die("Invalid query: ". mysql_error()); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo (" ID= ". $row["idno"]." "); } ?>

<?php $link = mysql_connect("mysql2.nevidia.com", "pgrocer.biz", "password", "pgrocer_biz_data") or die("Could not connect: ". mysql_error()); print ("Connected successfully"); mysql_select_db("pgrocer_biz_data"); $result idno, name from donor") or die("Invalid query: ". mysql_error()); while ($row = mysql_fetch_array($result)) { echo (" ID = ". $row["idno"]. " NAME = ". $row["name"]. " "); } ?>

<?php $link = mysql_connect("mysql2.nevidia.com", "pgrocer.biz", ”password", "pgrocer_biz_data") or die("Could not connect: ". mysql_error()); print ("Connected successfully"); mysql_select_db("pgrocer_biz_data"); $result * from donor") or die("Invalid query: ". mysql_error()); while ($row = mysql_fetch_array($result)) { echo (" ID = ". $row["idno"]. " NAME = ". $row["name"]. " "); echo("CITY = ". $row["city"]. " STATE = ". $row["state"]. " "); } ?>

<?php $link = mysql_connect("mysql2.nevidia.com", "pgrocer.biz", ”password", "pgrocer_biz_data") or die("Could not connect: ". mysql_error()); print ("Connected successfully"); mysql_select_db("pgrocer_biz_data"); $state="RI"; $result * from donor where state = '$state'") or die("Invalid query: ". mysql_error()); while ($row = mysql_fetch_array($result)) { echo (" ID = ". $row["idno"]. " NAME = ". $row["name"]. " "); echo("CITY = ". $row["city"]. " STATE = ". $row["state"]. " "); } ?>

<?php $link = mysql_connect("mysql2.nevidia.com", "pgrocer.biz", ”password", "pgrocer_biz_data") or die("Could not connect: ". mysql_error()); print ("Connected successfully"); mysql_select_db("pgrocer_biz_data"); $idno='11111'; $result * from donor where idno = '$idno'") or die("Invalid query: ". mysql_error()); $row = mysql_fetch_array($result); echo (" ID = ". $row[0]. " NAME = ". $row["name"]. " "); echo("CITY = ". $row["city"]. " STATE = ". $row["state"]. " "); ?>

<?php $link = mysql_connect("mysql2.nevidia.com", "pgrocer.biz", "whatever", "pgrocer_biz_data") or die("Could not connect: ". mysql_error()); print ("Connected successfully"); mysql_select_db("pgrocer_biz_data"); $sql = "INSERT INTO donor values ('33333', 'Al Richards', '111 South St', 'Braintree', 'MA', '02184',' ',300, 'John Smith')"; $result= mysql_query($sql,$link) or die(mysql_error()); echo $result; ?> Note that I did the insert as one long string that I had to wrap to show on the slide. I then ran connect7.php to show that the record got added.

<?php $link = mysql_connect("mysql2.nevidia.com", "pgrocer.biz", "whatever", "pgrocer_biz_data") or die("Could not connect: ". mysql_error()); print ("Connected successfully"); mysql_select_db("pgrocer_biz_data"); $sql = "INSERT INTO donor values ('44444', 'Sarah Grove', '123 Elm St', 'Seekonk', 'MA', '02345',' ',300, 'John Smith')"; $result= mysql_query($sql,$link) or die(mysql_error()); echo $result; ?> Again I wrapped for the slide, the insert is one line in my code. Indicates successful execution. When I executed insert1a.php a second time this error message was returned.

See insert on previous slide

<?php $link = mysql_connect("mysql2.nevidia.com", "pgrocer.biz", "whatever", "pgrocer_biz_data") or die("Could not connect: ". mysql_error()); print ("Connected successfully"); mysql_select_db("pgrocer_biz_data"); $sql = "INSERT INTO donor values ('45654', 'John Doe', '123 Elm St', 'Swansea', 'MA', '02345', ' ',300, 'John Smith')"; if (mysql_query($sql,$link)) { echo "record added"; } else { echo "must have been a duplicate"; } ?> Again note the wrap that is not in the code. When I ran insert1b.php a second time I got my duplicate message.

<?php $link = mysql_connect("mysql2.nevidia.com", "pgrocer.biz", "whatever", "pgrocer_biz_data") or die("Could not connect: ". mysql_error()); print ("Connected successfully "); mysql_select_db("pgrocer_biz_data"); $getidno='45654'; $sql = "DELETE FROM donor WHERE idno = '$getidno'"; if (mysql_query($sql,$link)) { echo "record deleted"; } ?>

<?php $link = mysql_connect("mysql2.nevidia.com", "pgrocer.biz", "whatever", "pgrocer_biz_data") or die("Could not connect: ". mysql_error()); print ("Connected successfully"); mysql_select_db("pgrocer_biz_data"); $getidno = '33333'; $sql = "UPDATE donor SET stadr = '111 North St' WHERE idno = '$getidno'"; $result= mysql_query($sql,$link) or die(mysql_error()); echo $result; ?>

The update changes the street name from South to North.

<?php $link = mysql_connect("mysql2.nevidia.com", "pgrocer.biz", "whatever", "pgrocer_biz_data") or die("Could not connect: ". mysql_error()); print ("Connected successfully"); mysql_select_db("pgrocer_biz_data"); $result * from donor") or die("Invalid query: ". mysql_error()); while ($row = mysql_fetch_array($result)) { echo (" ID = ". $row["idno"]. " NAME = ". $row["name"]. " "); echo ("STREET ADDRESS = ". $row["stadr"]. " "); echo("CITY = ". $row["city"]. " STATE = ". $row["state"]. " "); } ?>

Insert IDNO: NAME: STREET ADDRESS: CITY: STATE: ZIP: DATE FIRST CONTRIBUTED: YEAR GOAL: CONTACT:

<?php $link = mysql_connect("mysql2.nevidia.com", "pgrocer.biz", "whatever", "pgrocer_biz_data") or die("Could not connect: ". mysql_error()); print ("Connected successfully"); mysql_select_db("pgrocer_biz_data"); $idno=$_POST[inidno]; $name=$_POST[inname]; $stadr=$_POST[instadr]; $city=$_POST[incity]; $state=$_POST[instate]; $zip=$_POST[inzip]; $datefst=$_POST[indatefst]; $yrgoal=$_POST[inyrgoal]; $contact=$_POST[incontact]; $sql = "INSERT INTO donor values ('$idno', '$name', '$stadr', '$city', '$state', '$zip', '$datefst', '$yrgoal', '$contact')"; $result= mysql_query($sql,$link) or die(mysql_error()); echo $result; ?> The code has the insert on one line. I wrapped to fit on the slide.

Insert Enter the identification number for the record you want to delete. IDNO: <?php $link = mysql_connect("mysql2.nevidia.com", "pgrocer.biz", "whatever", "pgrocer_biz_data") or die("Could not connect: ". mysql_error()); print ("Connected successfully"); mysql_select_db("pgrocer_biz_data"); $idno=$_POST[inidno]; $sql = "DELETE FROM donor WHERE idno = '$idno'"; $result= mysql_query($sql,$link) or die(mysql_error()); echo $result; ?>

Insert Change the name for the following id. IDNO: NAME: <?php $link = mysql_connect("mysql2.nevidia.com", "pgrocer.biz", "whatever", "pgrocer_biz_data") or die("Could not connect: ". mysql_error()); print ("Connected successfully"); mysql_select_db("pgrocer_biz_data"); $idno=$_POST[inidno]; $name=$_POST[inname]; $sql = "UPDATE donor SET name = '$name' WHERE idno = '$idno'"; $result= mysql_query($sql,$link) or die(mysql_error()); echo $result; ?>