- 快召唤伙伴们来围观吧
- 微博 QQ QQ空间 贴吧
- 文档嵌入链接
- 复制
- 微信扫一扫分享
- 已成功复制到剪贴板
PHP + MySQL构建在线竞拍程序
展开查看详情
1 .Widhy Hayuhardhika NP, S.Kom Building an online bidding application using PHP/MySQL
2 .Outline Topic # 1 MySQL Connection
3 .Overview of database structure Connecting to MySQL database Selecting the database to use Using the require_once statement MySQL Database Connection
4 .Database: auction Tables tblaccount tblbiditems tblbidhistory Overview of Database connection
5 .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 Table tblaccount
6 .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 Table tblbiditems
7 .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 Table tblbidhistory
8 .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 Connecting to databases:
9 .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 Connecting to MySQL and selecting auction database
10 .Function require_once() Loads a file into a PHP script Reusing the database connection
11 .Outline Topic # 2 Creation of Accounts
12 .HTML form handling MySQL commands Function mysql_query() Function mysql_error() Adding records SQL insert statement Creation of accounts
13 .Create: File index.html File addaccount.html File addaccountprocess.php $_POST array HTML form handling
14 .First page that displays Provide the user with the option to create accounts File index.html
15 .Displays a form for accepting new account info File addaccount.html
16 .$_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 File addaccountprocess.php
17 .File addaccountprocess.php script
18 .Username: auctioneer1 This account will place items for bidding Usernames: bidder1, bidder2 These account will bid for item auctioned off Create accounts:
19 .Outline Topic # 3 Managing Logins
20 .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 Managing logins
21 .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’ SQL select statement
22 .Retrieves the number of rows from a result set Can only be used for SQL select statements Function mysql_num_rows
23 .Checks if a variable exist Example: isset($name) This check if the variable $name exist Function isset()
24 .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 Sessions
25 .Querystring Information can be passed on by appending variable/value to the URL $_GET array Special array that holds all querystring values URL Rewriting
26 .File login.php code
27 .File login.php browser shot
28 .File loginverify.php code
29 .File checkstatus.inc code