Widhy Hayuhardhika NP, S.Kom. Overview of database structure Connecting to MySQL database Selecting the database to use Using the require_once statement.

Slides:



Advertisements
Similar presentations
PHP: Date() Function The PHP date() function formats a timestamp to a more readable date and time.
Advertisements

Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizards Guide to PHP by David Lash.
LIS651 lecture 2 mySQL and PHP mySQL functions Thomas Krichel
PHP II Interacting with Database Data. The whole idea of a database-driven website is to enable the content of the site to reside in a database, and to.
PHP SQL. Connection code:- mysql_connect("server", "username", "password"); Connect to the Database Server with the authorised user and password. Eg $connect.
Database Chapters.
PHP Hypertext Preprocessor Information Systems 337 Prof. Harry Plantinga.
Keys, Referential Integrity and PHP One to Many on the Web.
PHP and MySQL Database. Connecting to MySQL Note: you need to make sure that you have MySQL software properly installed on your computer before you attempt.
Faculty of Sciences and Social Sciences HOPE PHP & MySQL Stewart Blakeway FML 213
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
PHP (2) – Functions, Arrays, Databases, and sessions.
Manipulating MySQL Databases with PHP. PHP and mySQL2 Objectives Connect to MySQL from PHP Learn how to handle MySQL errors Execute SQL statements with.
Objectives Connect to MySQL from PHP
Intermediate PHP & MySQL
Figure 1. Hit analysis in 2002 of database-driven web applications Hits by Category in 2002 N = 73,873 Results Reporting 27% GME 26% Research 20% Bed Availability.
© Yanbu University College YANBU UNIVERSITY COLLEGE Management Science Department © Yanbu University College Module 6:WEB SERVER AND SERVER SIDE SCRPTING,
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Cookies & Sessions.
MySQL in PHP – Page 1 of 17CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: MySQL in PHP Reading: Williams &
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
_______________________________________________________________________________________________________________ PHP Bible, 2 nd Edition1  Wiley and the.
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
Introduction to MySQL Lab no. 10 Advance Database Management System.
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.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Lec_6 Manipulating MySQL Databases with PHP PHP Programming with MySQL.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
PHP and MySQL CS How Web Site Architectures Work  User’s browser sends HTTP request.  The request may be a form where the action is to call PHP.
1. Connecting database from PHP 2. Sending query 3. Fetching data 4. Persistent connections 5. Best practices.
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.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
CHAPTER 9 PHP AND MYSQL. A POSSIBLE SITE CONFIGURATION Application Folder index.php includes (folder)header.phpfooter.phpstyle.cssmodel (folder)mysqli_connect.php.
Creating PHPs to Insert, Update, and Delete Data CS 320.
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.
PHP Database Processing CIS 1715 Web Technologies.
Server-Side Scripting with PHP ISYS 475. PHP Manual Website
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.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
PHP Programming. Topics Database Handling (MySQL, MSSQL, ODBC)
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.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
COM621: Advanced Interactive Web Development Lecture 10 PHP and MySQL.
2440: 141 Web Site Administration Web Forms Instructor: Joseph Nattey.
Web Database Programming Using PHP
PHP (Session 2) INFO 257 Supplement.
Databases.
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
SQL and SQL*Plus Interaction
Open Source Server Side Scripting Permissions & Users
Web Database Programming Using PHP
Chapter 19 PHP Part III Credits: Parts of the slides are based on slides created by textbook authors, P.J. Deitel and H. M. Deitel by Prentice Hall ©
ISC440: Web Programming 2 Server-side Scripting PHP 3
Web DB Programming: PHP
Introduction to Web programming
CS4540 Special Topics in Web Development SQL and MS SQL
Presentation transcript:

Widhy Hayuhardhika NP, S.Kom

Overview of database structure Connecting to MySQL database Selecting the database to use Using the require_once statement

Database: auction Tables tblaccount tblbiditems tblbidhistory

This will hold the account info of bidders/ auctioneers Table structure Column accountid: integer, primary key, auto-increment Column username: string 50 chars Column password: string 50 chars

This will hold the items auctioned for bidding Table structure Column biditemid: integer, primary key, auto-increment Column accountid: string 50 chars This identifies the auctioneer Column biditem: string 50 chars Column biddesc: tiny text

This will hold the bid info for each item being auctioned Table structure Column bidhistoryid: integer, primary key, auto- increment Column accountid: integer Column biditemid: integer Column bidprice: double Column dtesubmitted: datetime

Function mysql_connect: Creates a connection to MySQL Syntax: mysql_connect($hostname, $username,$password) Ex: $conn=mysql_connect(localhost, root,password) Function mysql_select_db Specifies the database in MySQL for use Syntax: mysql_select_db($database, $connection) Ex: mysql_select_db(auction, $conn) Function die Terminates execution of PHP script

Create file dbconnect.inc For code reuse, a separate file can be created to connect to the database PHP pages can call dbconnect.inc to connect yo the auction database

Function require_once() Loads a file into a PHP script

HTML form handling MySQL commands Function mysql_query() Function mysql_error() Adding records SQL insert statement

Create: File index.html File addaccount.html File addaccountprocess.php $_POST array

First page that displays Provide the user with the option to create accounts

Displays a form for accepting new account info

$_POST array Special arrays that hold all form variables Function mysql_query() Executes an SQL statement on the database Function mysql_error() Displays error encountered when executing an SQL statement SQL Insert Adds a record on a database table

Username: auctioneer1 This account will place items for bidding Usernames: bidder1, bidder2 These account will bid for item auctioned off

SQL select statement Function mysql_num_rows Function isset() Session URL rewriting Querystring $_GET array Create: File login.php File loginverify.php File checkstatus.inc File menu.php

Example 1: select * from tblaccount Selects all columns/ rows from table tblaccount Example 2: select username, password from tblaccount Selects columns username and password for all rows in table tblaccount Example 3: select * from tblaccount where username=jundolor Selects all columns from table tblaccount for all rows whose column username contains jundolor Example 4: select accountid from tblaccount where username=media Selects column accountid from tblaccount for all rows whose column username contains media

Retrieves the number of rows from a result set Can only be used for SQL select statements

Checks if a variable exist Example: isset($name) This check if the variable $name exist

Special variables stored in web servers Allows passing of information between web pages Call the function session_start() at the start of scripts that will use sessions

Querystring Information can be passed on by appending variable/value to the URL $_GET array Special array that holds all querystring values

File menu.php Create: File addauctionitem.php File addauctionitemprocess.php

Function mysql_fetch_array() Writing querystring URL to identify records to delete SQL delete statement Create: File listauctionitems.php File: deletebiditem.php

Fetches a row as an associative from a select query result set

Auction items belonging to current account will be selected A loop will be created to go through each row Each row will hyperlink to a PHP based page for deletion To identify the row, a querystring variable will be appended to the URL

Example 1: delete from tblaccount Deletes all rows on table tblaccount Example 2: delete from tblaccount where accountid=1 Deletes only rows matching the condition

Function session_destroy() Create: File logout.php

Terminates all session variables stored in server memory

Once logout.php is called, all session variable will be dropped from server memory Browser will not be able to access any page calling checkverify.php (ex: menu.php)

Establishing relations between tables SQL natural join clause Create: File listbiditems.php

Table tblbiditem Holds the items being auctioned off Column accountid identifies the owner if the auctioned item Table tblaccount Holds account information of the owner of the item being auctioned Column accountid Links the owner of the account to the auction item

Used with SQL select statement Connects rows between different tables via their common column

All items with their respective owners being auction are listed Each item will hyperlink to a PHP page for accepting bids Accepting bids will be covered in the next topic section Each hyperlink will append a querystring variable to identify it in the PHP page for accepting bids

Using hidden fields to store ID numbers MySQL now() function Create: File acceptbid.php File acceptbidprocess.php

Not displayed to the browser Used to pass constant values

Place the id of the auction item in a hidden field

Returns the current date and time as a value in 'YYYY- MM-DD HH:MM:SS' or YYYYMMDDHHMMSS.uuuuuu format depending on whether the function is used in a string or numeric context The value is expressed in the current time zone.

MySQL date_format() function Relating information from two or more tables SQL order by clause

Formats a string based on a specified format The following are some of the specifies of the format string: %D: Day of month with English suffix %d: Numeric day of month (01…31) %M: Month name (January…December) %m: Month numeric (01…12) %Y: Year (4 digits) %y: Year (2 digits)