PLAGIARISM FREE WRITING SERVICE
We accept
MONEY BACK GUARANTEE
100%
QUALITY

Web Database Founded Inventory System

Content
  1. 1. 1. Project objectives
  2. The objectives of the project are:
  3. 1. 2. Personal objectives
  4. 1. 2. 1. Career objectives
  1. 1. 2. 2. Academic objectives
  2. 1. 3. Project Limitations
  3. 1. 4. Gantt chart
  4. 1. 5. Literature review
  5. Information Systems Analysis
  6. Database
  7. Database Management System
  8. Database server
  9. Database tier
  10. 1. 6. Complex review
  11. 1. 6. 1. Wed Based mostly Database Systems development tools
  12. 1. 6. 2. Web Based Repository development technologies
  13. PHP is a Scripting Dialect that is interpreted on the web server prior to the webpage is delivered to a web browser to be shown. This is seen in the expanded PHP recursive acronym PHP-Hypertext Pre-processor.
  14. 1. 7. Solutions used
  15. 1. 7. 1. PHP and MySQL
  16. 1. 7. 2. Why use PHP and MySQL
  17. 1. 8. Methodologies Approach
  18. 1. 8. 1. Prototyping
  19. 1. 8. 2. Quick Application Development
  20. 1. 8. 3. Chosen Methodology
  21. CHAPTER 2 ANALYSIS
  22. 2. 1. Bakery Feyasse profile
  23. 2. 2. Existing system (appendices)
  24. 2. 2. Current Systems
  25. 2. 2. 1. Benefits with current system
  26. 2. 2. Users Requirements
  27. 2. 3. System Specification
  28. 2. 4. Use Cases
  29. Use cases description (appendices)
  30. CHAPTER 3DESIGN
  31. 3. 1. Architectural Design
  32. 3. 1. 1. Entities and Attributes
  33. 3. 1. 2. Connecting To Database
  34. In order to concern MySQL data manipulation statements, we must specify a username, a password and a database to work with. This information will have been provided from your systems adminsistrator. If you're running MySQL yourself, then skip forward to the section on Developing a Database in Part 6 - then come back to this aspect.
  35. Either way you should now have in your ownership a database name, a valid security password to the database and a password. For the purposes of these workshops the following example worth will be utilized.
  36. Database Name
  37. vworksDB
  38. Valid MySQL Username
  39. vworks
  40. Password
  41. mypass
  42. In order to log into MySQL appropriately we must pass information to the MySQL customer program whenever we start it. That is done with the next commands and syntax.
  43. $ mysql -u -p
  44. 3. 1. 2. Database Design using MySQL
  45. +------------------+-------------+------+-----+---------+----------------+
  46. +------------------+-------------+------+-----+---------+-----
  47. +------------------+-------------+------+-----+---------+----------------+
  48. +-------------+-------------+------+-----+---------+-------+
  49. +------------+-------------+------+-----+---------+-------+
  50. +-------------+-------------+------+-----+---------+-------
  51. +--------------+-------------+------+-----+---------+----------------+
  52. +--------------+-------------+------+-----+---------+----------------+
  53. +--------------+-------------+------+-----+---------+----------------+
  54. +---------------------+-------------+------+-----+---------+---------------
  55. +---------------------+-------------+------+-----+---------+---------------
  56. +---------------------+-------------+------+-----+---------+---------------
  57. 3. 4. Database Normalisation (Appendices)
  58. 3. 5. Entity Relationship
  59. 3. 5. SQL QUERIES
  60. Talking to Databases Using SQL
  61. SQL can be an abbreviation for Structured Query Language. It is a unusual natural language that allows us to "talk" to relational databases, such as MySQL, to require and improve data. In addition, it allows us to get information about and adjust the framework which has the data, databases themselves, and furniture within them. The inquiries produced with SQL can range from the simple to the complex, which makes it an extremely powerful tool for working with data
  62. +--------+------------------+--------------------+------------
  63. +--------+------------------+--------------------+------------
  64. +--------+------------------+--------------------+------------
  65. +--------+------------------+--------------------+------------
  66. +--------+------------------+--------------------+------------
  67. +--------+------------------+--------------------+------------
  68. 3. 6. Web Database Structure
  69. Description of website:
  70. 3. 6. 1. Menu structure
  71. 3. 6. 1. 1. Order page structure
  72. 3. 6. 1. 2. Select Order page
  73. 3. 6. 1. 3. Add Order Page
  74. 3. 6. 1. 4. Upgrade Order page
  75. 3. 6. 1. 5. Delete Order page
  76. Working with Existing Databases through PHP
  77. Things to Remember
  78. Connecting to MySQL
  79.  
  80. Selecting a Database
  81. Querying the Database
  82. SELECT
  83.  
  84. INSERT
  85. UPDATE
  86. DELETE
  87. A person using their web browser requests a active PHP web site, the webserver has been configured to recognise the. php expansion and goes by the record to the PHP interpreter which moves an SQL query to the MySQL server coming back results for PHP to display. You can also use the PHP script to productivity HTML throughout the results to ensure that the results are formatted very well for display inside a browser. It really is vital that the record has a. php expansion or the web server will not know to go it to the interpreter.
More...

Web database established inventory system is for management of items, orders, customers and repayment. This system assists with Stock management, repayment, and orders. This system allows conducting payment for customers and then for ordered items in the purchase order. The main objective of this project is approximately the design of Web-based inventory system.

Bakery feyasse use traditional paper centered inventory system to manage his information concerning customer, ordered item, item and repayment. There are many problems with this technique such as time consuming, hard labour and sometimes lost of information. The sales development and order misplacement result in a lot of benefit Bakery Feyasse.

The manual system is prone to errors resulting major complaints from customers.

The level of data and complexity of research to be conducted seems overwhelming using their manual system which sometimes boosts suspicions of went back results that are also difficult to correct or check. After careful analysis, discussion thorough research of existing method, it was agreed a new effective system must solve Bakery Feyasse problems.

After reviewing the possible design alternatives, it was made a decision that MySQL database and PHP script terminology is the greatest inexpensive fit for Bakery Feyasse system in conditions of cost, simple maintenance, user interface design and upgradability using Microsoft house windows program. The database would be connect to the business's website via PHP script vocabulary. The online server will permit employee to enter into, create, upgrade and delete information online.

1. 1. Project objectives

1. To create a system that will aid the Bakery employee at their different task

2. To explore the ideas involved in the development of an internet database inventory site.

This web database inventory system includes the main function as following:

Select data from database

Update information in to the database

Delete information from database

And add information into database

The objectives of the project are:

Design a relational database

Implement this database

Testing the new system

Evaluate the system

1. 2. Personal objectives

My personal objective for this task is to complete the project on time. I set up a every month time table to handle different task. My enthusiasm is that after concluding this project. I will gain more knowledge in computer technology. To permit me to achieve success this job, I used the abilities I gain last year in MySQL, and SQL. I also understand how to create a dynamic site which I didn't know. I learn new script language which is PHP.

1. 2. 1. Career objectives

Gain my BSc Honours Level.

Gain more skills in Programming language, Processing science and Information Systems Systems.

1. 2. 2. Academic objectives

1. Learn program writing language such as PHP and MySQL

Learn how to use PHP script vocabulary to create a form to get information from website

Learn how to hook up MySQL Database with dynamic Website

How to work with PHP code to retrieve information from MySQL database

How to create HTML form

How to make use of HTML form to retrieve information from database

How to build database table using MySQL application.

1. 3. Project Limitations

I am totally conscious that my project is to make a web database system which is not an easy task and I am also aware of the short I've got to make this happen task. So the time is my target. I am thinking of finish on time. Time management has been considered because; I also received one exam to get ready.

1. 4. Gantt chart

1. 5. Literature review

At the start of my project, the researches have been made to gathering information because many activities go into the development of a fresh system. Understanding system requirements, choosing database-tier software, building databases, and building the tier are the first steps in successful web database software development. The next issues have been explored:

Information System Analysis

Database

Database management systems

Database Server

Database tier

Information Systems Analysis

System Analysis

System Design

This period show the way the system run.

Prototype

This phase will allow the employee to understand the operation of the new system.

Implementation

Development of the new system

Testing

The new system is tested to be able to validate its functions

Database

A database is a assortment of related data. The info stored is rows, which make up a simple customers, items, orders and repayment details.

Database Management System

Database Management System enables the users to get relevant information. It refers to information infrastructures that compose of relevant information. Database system creates and keeps a database and permits individual business software to extract the info in order to produce report.

Database server

Database server is a system designed to manipulate the database. Its function is to store, retrieve, and manage information. Its works an important role in web services and the n-tier interconnection through the Internet users via their browser.

Database tier

Database tier is the base of a web database application. In a three-tier architecture request, the database tier manages the info. The info management typically includes storage space and retrieval of data, as well as managing updates, access by several middle-tier process, providing security, ensuring the integrity of data, and providing support services such as data backup.

1. 6. Complex review

The web based database inventory system is creating using MySQL software and PHP script terms. The interface of the system is developed with Hypertext Markup Words (HTML). The machine is accessible anywhere that have usage of Internet.

1. 6. 1. Wed Based mostly Database Systems development tools

Dreamweaver CS3

Dreamweaver CS3 Dreamweaver is a full-featured Web application development tool. Its features not only help with creation and editing Web pages, but also with managing and retaining the entire Site.

MySQL

MySQL implies the Client /Server architecture, which compose of an server process and customer process. A server process manages the reasonable repository management. A sever process requires of how the data is stored and sorted out.

The consumer process would be described as process that accesses the server in order to store, get, update and modify the databases schema.

SQL

SQL (Structured Query Terminology) SQL used to talk to most databases. You may manage your databases, retrieve data from it, or add data to it using SQL questions. You build and send an SQL query to the data source. The data source responds by carrying out the action described by the query or, if the data source struggles to perform the wanted operation, its earnings error concept with information about the problem.

Cold Fusion

ColdFusion is a tagged terminology, produced by Macromedia, who is also the programmer of Dreamweaver. A stand-alone Web server is also included within ColdFusion. The stand-alone server is fine development, but you should use a more powerful Internet site.

ASP

ASP Program Server Pages (ASP) is Microsoft technology. It built into IIS (Internet Information Server). When you use ASP technology; you have the selection of languages VBScript or JScript. While you create your Dreamweaver site, you identify which vocabulary you want to utilize.

1. 6. 2. Web Based Repository development technologies

PHP

PHP is a Scripting Dialect that is interpreted on the web server prior to the webpage is delivered to a web browser to be shown. This is seen in the expanded PHP recursive acronym PHP-Hypertext Pre-processor.

1. 7. Solutions used

1. 7. 1. PHP and MySQL

PHP and MySQL work in combination, where the repository is MySQL and the script words is PHP.

How PHP and MySQL interact?

PHP gather information and MySQL store information. PHP will generate retrieve information form for the machine, but MySQL keep carefully the information in a format PHP.

1. 7. 2. Why use PHP and MySQL

PHP and MySQL incorporate mutually make easy the development of a dynamic Website. HTML creates useful web pages by adding PHP and MySQL where you can collect information.

1. 8. Methodologies Approach

1. 8. 1. Prototyping

Prototyping is most appropriate strategy for systems which include data querying, online data upgrading, and on-line data reporting functions. It can be used to create appropriate data access interfaces for users and also to help identify the functions that users would like in the machine, like the options over a menu employed by the a system.

1. 8. 2. Quick Application Development

Its basic process is to get systems personnel and users jointly in formal meetings, where they quickly develop systems that provide users with the information needs.

1. 8. 3. Chosen Methodology

Prototyping Methodology Development choice has been influenced by several factors:

1. Clarify the user requirements

2. Knowledge of the base technology

3. System complexity

4. Dependence on the system reliability

5. Time pressure

6. Have to see improvement on enough time schedule.

7. So when timelines are short because they best permit me to change the

functionality in the system on the basis of a particular delivery day.

CHAPTER 2 ANALYSIS

2. 1. Bakery Feyasse profile

Bakery Feyasse is a Bakery that was made by Malan Kouao in 1988. The business started in 1988 with one Bakery and after continuous progress another Bakery has been created in 2008. The diagram below show the Bakery Structure

Production manager

Sale manager

Manager

Chairman

Department manager

Department manager

Department manager

Fig: Bakery's Feyasse structure

2. 2. Existing system (appendices)

The Bakery use traditional newspaper based where in fact the worker checks the availability of the things by querying the items catalogs, and fills the book by using paper and pen. In addition the ordering process is made by pen and palm which is time consuming to get hold of the development and it triggers slow moving for the client order and there is threat of mistake caused by the staff.

All employee access the same data, share the same information. The salesperson check the availability of the items by querying the development department. The development department check the option of the things from the e book register by hand. After knowing the supply, he fills the availability book physically so that the salesperson will know which item can be obtained. The account director checks the stock items physically to be able to re order the product. The information about the item, the clients, and the suppliers is maintained in a short-term contact book

2. 2. Current Systems

The suggested system is a web based inventory system. The staff of each section can work peacefully at their office. The machine allows the personnel to fill the order payment, the order, that order form. The aim of the new system is to make an online gain access to database to store all data concerning the Bakery.

The main activities performed by the machine are.

The system provides data processing and storage area.

The system screen system functionality.

The system features is obtainable by clicking selected task.

The system allows the staff to put information through the picked page.

The system allows the staff to cancel information.

The system allows the staff to process a repayment.

The system will allow the staff to revise information.

2. 2. 1. Benefits with current system

1. To increase the good company in item availableness, customers 'details, orders, bought items and repayment data inputting by using database system.

2. Salespersons will be able to view the set of items made by the production team anytime

3. Customers details can be kept

4. Order can be placed for future every month report.

System Requirement Analysis

At this stage I met an individual to obtain a detailed understanding of Bakery needs. A functional specification, process model, reasonable model are described.

Analysis of the situation where Bakery Feyasse look for a remedy with the new system

Defining the problem

Identify the challenge causes

Specifying the solution

Identifying the users requirements,

And figuring out new opportunity for using new technology

2. 2. Users Requirements

Define the goals of the new system and develop a detailed information of the function that the new system will perform

The system provides data control and storage area.

The system screen system efficiency.

The system operation is accessible by clicking preferred task.

The system allows the personnel to place information through the preferred page.

The system allows the staff to cancel information.

The system allows the staff to process a payment.

The system allows the staff to revise information.

The manager will be able to get the job done of the salesperson

2. 3. System Specification

The system would permit end-users (employee) to build, update information

All information about customer, item, order and payment will be stored in a database, that your web database inventory system will display through different interfaces

Allows the deletion and appends information

Facility to query the database

Enables the manipulation of sales activities

Tracking consumer activities using the system

2. 4. Use Cases

Select order/customer details

Add order/customer details

Delete order/customer details

Update order/customer details

Use cases description (appendices)

CHAPTER 3DESIGN

3. 1. Architectural Design

Logical design

Physical design

3. 1. 1. Entities and Attributes

Bakery Feyasse will have a relational database system with the next entities and features.

customer (cust_id, cust_name, cust_address, cust_city)

order(order_id, cust_id*, item_id*, quantity, item_price, total_price)

payment(order_id*, payment_id, payment_type, repayment_description, amount)

item(item_id, item_name, item_price, item_information)

3. 1. 2. Connecting To Database

In order to concern MySQL data manipulation statements, we must specify a username, a password and a database to work with. This information will have been provided from your systems adminsistrator. If you're running MySQL yourself, then skip forward to the section on Developing a Database in Part 6 - then come back to this aspect.

Either way you should now have in your ownership a database name, a valid security password to the database and a password. For the purposes of these workshops the following example worth will be utilized.

Database Name

vworksDB

Valid MySQL Username

vworks

Password

mypass

In order to log into MySQL appropriately we must pass information to the MySQL customer program whenever we start it. That is done with the next commands and syntax.

$ mysql -u -p

3. 1. 2. Database Design using MySQL

MySQL database comprises of database which includes tables. A desk is a section of the database for stocking information.

mysql> show columns from item;

+------------------+-------------+------+-----+---------+----------------+

| Field | Type | Null | Key | Default | Extra |

+------------------+-------------+------+-----+---------+-----

| item_id | int(11) | NO | PRI | NULL | vehicle_increment |

| item_name | varchar(50) | YES | | NULL | |

| item_price | float(6, 2) | YES | | NULL | |

| item_explanation | words | YES | | NULL | |

+------------------+-------------+------+-----+---------+----------------+

mysql> show columns from order; a refaire

+-------------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+------------+-------------+------+-----+---------+-------+

| order_id | int(11) | YES | | NULL | |

| item_id | varchar(50) | YES | | NULL | |

| amount | int(11) | YES | | NULL | |

| item_price | float(6, 2) | YES | | NULL | |

| total_price | float(6, 2) | YES | | NULL | |

+-------------+-------------+------+-----+---------+-------

mysql> show columns from customer;

+--------------+-------------+------+-----+---------+----------------+

| Field | Type | Null | Key | Default | Extra |

+--------------+-------------+------+-----+---------+----------------+

| cust_id | int(11) | NO | PRI | NULL | vehicle_increment |

| cust_name | varchar(20) | YES | | NULL | |

| cust_address | varchar(20) | YES | | NULL | |

| cust_city | varchar(25) | YES | | NULL | |

| cust_phone | varchar(25) | YES | | NULL | |

+--------------+-------------+------+-----+---------+----------------+

mysql> show columns from payment;

+---------------------+-------------+------+-----+---------+---------------

| Field | Type | Null | Key | Default | Extra

+---------------------+-------------+------+-----+---------+---------------

| repayment_id | int(11) | NO | PRI | NULL | vehicle_increment

| order_id | int(11) | YES | | NULL |

| order_night out | time frame | YES | | NULL |

| payment_type | varchar(10) | YES | | NULL |

| payment_description | varchar(20) | YES | | NULL |

| amount | float(6, 2) | YES | | NULL |

+---------------------+-------------+------+-----+---------+---------------

3. 4. Database Normalisation (Appendices)

1NF

customer(cust_id, cust_name, cust_address, cust_city)

order (order_id, cust_id*, item_id*, quantity, item_price, total_price)

payment(order_id*, payment_id, payment_type, payment_description, amount)

2NF

customer(cust_id, cust_name, cust_address, cust_city)

order (order_id, cust_id*, volume, total_price)

payment(order_id*, repayment_id, payment_type, payment_description, amount)

item(item_id, item_name, item_price, item_description)

3NF

customer(cust_id, cust_name, cust_address, cust_city)

ordered_item(order_id, quantity, total_price)

payment(order_id*, repayment_id, amount)

item(item_id, item_name, item_price, item_explanation)

payment_type(payment_type, repayment_description)

3. 5. Entity Relationship

There are three types of romantic relationship.

One-to-one marriage means the particular one of each thing is employed in the relationship

One-to-many romantic relationship means one row in a single table is associated with many row in another table.

Many-to-many relationship means many rows in one table are associated with many rows in another stand.

3. 5. SQL QUERIES

Talking to Databases Using SQL

SQL can be an abbreviation for Structured Query Language. It is a unusual natural language that allows us to "talk" to relational databases, such as MySQL, to require and improve data. In addition, it allows us to get information about and adjust the framework which has the data, databases themselves, and furniture within them. The inquiries produced with SQL can range from the simple to the complex, which makes it an extremely powerful tool for working with data

Inserting, Updating, Selecting and Deleting.

Insert data into database table

The INSERT INTO statement is used to add new record in a table.

Syntax

INSERT INTO stand_name

VALUES (value1, value2) [guide]

mysql> INSERT INTO CUSTOMERS VALUES(

-> 10, 'Gnahore Hortense', '34 webster street', 'Bermondsey'),

-> (11, 'Kouakou Nkruma', '10 salisbury judge', 'London');

mysql> SELECT * FROM CUSTOMERS;

+--------+------------------+--------------------+------------

| CustID | NAME | ADDRESS | CITY

+--------+------------------+--------------------+------------

| 10 | Gnahore Hortense | 34 webster highway | Bermondsey

| 11 | Kouakou Nkruma | 10 salisbury court | London

+--------+------------------+--------------------+------------

Select data from a database stand.

The SELECT statement is used to choose data from a database.

Syntax

SELECT column_name [guide]

FROM desk_name

mysql> SELECT * FROM CUSTOMERS;

+--------+------------------+--------------------+------------

| CustID | NAME | ADDRESS | CITY

+--------+------------------+--------------------+------------

| 10 | Gnahore Hortense | 34 webster street | Bermondsey

| 11 | Kouakou Nkruma | 10 salisbury court docket | London

+--------+------------------+--------------------+------------

Update data in a database existing details in a stand.

The UPDATE affirmation is used to change data in a desk.

Syntax

UPDATE table_name

SET column1=value, column2=value2 [Reference]

WHERE some_column=some_value.

mysql> UPDATE CUSTOMERS

-> Place ADDRESS ='45 clement road'

-> WHERE CustID =11;

Delete data in a database

The DELETE FROM affirmation is utilized to delete records from a database.

Syntax

DELETE FROM desk_name

WHERE some_column= some value [reference]

3. 6. Web Database Structure

Home page

Description of website:

3. 6. 1. Menu structure

BAKERY FEYASSE

MAIN MENU

CUSTOMER ITEM ORDER PAYMENT

Page information:

3. 6. 1. 1. Order page structure

BAKERY FEYASSE

ORDER

SELECT ORDER ADD ORDER UPDATE ORDER DELETE ORDER

Page information:

3. 6. 1. 2. Select Order page

3. 6. 1. 3. Add Order Page

3. 6. 1. 4. Upgrade Order page

3. 6. 1. 5. Delete Order page

SQL is not exclusive to MySQL, nor should it be mistaken as being a part of PHP. It's also not the one database query words out there. It is, however, typically the most popular. If you understand how to speak SQL, that knowledge means a variety of other popular database products.

Working with Existing Databases through PHP

Whether you are employing PHP and MySQL, or another combo, the same basic process of working with a database can be applied.

First, a link with the database server is set up. This interconnection usually continues for the lifetime of the running script. Additionally, as you will later see, there are instances where they could be contiguous across scripts.

Next, a specific database is chosen to work with. Only one database at the same time can be decided on per connection, but you can move to different databases without terminating the connection. You can also have multiple associations set up within the script, each with an unbiased particular database.

Finally, after you have a connection founded and a database determined, you can get started to work with the furniture within them by using SQL to issue various commands. Data can be retrieved, added, improved, or erased, and changes can be produced to the decided on database itself.

When finished, the bond to the database server is terminated personally with mysql_close(), or automatically with the finish of the script.

Let's take a closer look at each step separately

Things to Remember

MySQL is a popular relational database product

SQL is a terms used to communiate with MySQL (and other databases). It allows information to be retrevied, revised, and deleted. In addition, it provides a means to modify databases and dining tables.

Databases are similiar to associative arrays. Each database can contain one or more dining tables. Each table comprises records divided into fields.

Working with a database via a PHP script follows this basic process: Hook up to the server, decide on a database, perform any concerns on the database, close the connection.

SELECT, INSERT, Upgrade, and DELETE constitute SQL's data manipulation commands.

The data retreived from a table can be limited in various ways: Specific columns can be went back by including them within the query, the WHERE clause may be used to to include or exclude specific documents, and LIMIT can cover the amount of entries that are came back.

Results can be sorted using the ORDER BY clause. By default, String Type fields are sorted alphabetically; Numeric Type fields are sorted from smallest to largest.

When creating a new table in a database, a distinctive stand name must be specified. Furthermore, a name, field type, and period are defined for each column in the table.

In nearly every case, a desk should have an AUTO_INCREMENT Key ID column identified.

All of PHP's MySQL controlling functions go back FALSE when there is an error in the query or the query fails. Using mysql_error() returns the exact error reported by MySQL.

Connecting to MySQL

Just such as a multi-user computer system or an FTP server, MySQL allows different user accounts to be proven with individual degrees of access. To determine a connection to MySQL, three bits of information are essential: the hostname of the database server, the username for the accounts, and the associated password.

This information is transferred to the mysql_connect() function, which endeavors to establish the connection:

$connect = mysql_connect('hostname', 'username', 'security password');

The function results a value TRUE on success, and FALSE on failing, so it is useful (though not necessary) to assign the function to a variable. Inside the above example, $hook up is used. It could be evaluated to avoid executing any additional concerns if the connection attempt failed:

if ($connect==FALSE)

print "Database connection failed";

exit;

 

It is also beneficial to store the ends up with a variable because the function profits a unique interconnection identifier upon success. The variable then can be approved to some of PHP's MySQL handling functions (typically as the next parameter) to designate that this database interconnection should be utilized, as opposed to any other productive ones within the script.

Selecting a Database

Once an association is established, the next step is to select a database. To do this, all that is needed is the name of an existing database:

mysql_select_db('database');

As with mysql_connect(), this function comes back TRUE or Wrong depending on whether the database was efficiently selected. To specify which interconnection the function should use, we can go an association identifier to the function:

mysql_select_db('database', $connect);

Without the next parameter, the function uses the database connection that was previous set up within the script.

Querying the Database

The mysql_query() function is essentially a PHP wrapper for accomplishing SQL commands. Any valid and complete SQL assertion can be handed down as a parameter to this function.

Four types of inquiries make up SQL's data manipulation statements. They are as follows: SELECT, Revise, Put in, and DELETE.

SELECT

The SELECT query is used to get data from one or more furniture in a database. As you'll learn later, we can also select data from multiple dining tables using Stand Joins, however the simplest kind of SELECT statement works together with only one stand at the same time. The syntax looks like this:

SELECT * FROM users

Essentially, this affirmation says, "Select all the fields in all the rows of the stand called users. " The asterisk is a untamed card personality that instructs MySQL that it should grab anything available in the particular tables.

To require this data from a PHP script, we go away the query to the mysql_query () function. Because we expect documents to be came back from the database, the function must be allocated to a variable. The query is a string, so PHP requires it to be surrounded by prices. (Variables tend to be passed within questions and SQL requires that string ideals in WHERE clauses and Put claims be surrounded with solitary quotes. Though sole quotes can be utilized here, it is normally preferable to use double insurance quotes for clarity. )

$final result = mysql_query ("SELECT * FROM users");

Just like mysql_connect () and mysql_go for_db (), this function will gain FALSE if there is an error in the SQL. When the function is prosperous, however, $final result will keep a resource identifier.

Because the changing just holds an identifier, we can not get any of our data by outputting $final result. To get the data, we need to pass the result to another PHP function, mysql_fetch_array (). This function results a range of each record from a SELECT query, collection by line. Unless you know for a fact that your query will only return an individual record, it is highly recommended to employ a while loop to itinerate through each row of the result placed. The function retains an interior place mark which record it is on, therefore the loop will terminate once all the files have been came back. Let's go back to our sample database right away of this article and the select affirmation above to observe how you would end result the info:

while ($row = mysql_fetch_array($consequence))

printing $row['id']. ', '. $row['name']. ', '. $row['email']. '

';

 

Notice that the array indexes of $row match the column brands of the stand. The array generated by mysql_fetch_array() can optionally be an associative or a numeric array. By default, details are accessible by both types of secrets. So, the id column (the first column in the table) can be accessed as $row['id'] or $row[0];

INSERT

INSERT can be used to add a new record to a stand. The syntax appears like this:

mysql_query("INSERT INTO users ('id', 'name', 'email') Prices('', 'Name', ''");

By now, the first part of the query should look rather familiar to you. It commences with the SQL command line we are going to perform, in this case INSERT. Because we have been inserting a new record, INTO is roofed, followed by the name of the table we have been adding it to.

The first group of parentheses surrounds a set of the fields within the table. These must be listed in the same order that they take place in the real table.

The second portion defines the worth that are going to be added. They must match the order of the fields within the query and the table for them to be put in the proper location.

Like the field labels, SQL requires that all value be surrounded by estimates, because they are strings. When there is no value to be placed, the positioning for the value must be reserved by using clear quotes.

If you are inserting worth for all of the fields, the field list may be overlooked:

mysql_query("Put in INTO users Worth('', 'Name', ''");

MySQL will insert the values in to the columns in the order that they show up.

UPDATE

So way we've protected selecting and adding information to a table, but what if you want to improve existing data? Revise allows us to do that. The essential syntax for an UPDATE affirmation appears like this:

mysql_query("Upgrade users place email=''");

In this case, we're updating stand users, and changing the value of the column called email to "". Take another look at the query. You'll observe that we've not given which records should have the field email up to date. If this query were run, all the fields called "email" in every the records would be modified. To confine the changes to an individual (or multiple) specific information, the WHERE clause makes a re-appearance. Within the select affirmation, it was used to evaluate which records should be returned; here, it is used to judge which files should be kept up to date:

mysql_query("UPDATE users arranged email='' where id='1'");

Now, only records where the id amount has a value of one will be modified.

Multiple fields within the same record can even be updated. In such a example, both name and email are changed:

mysql_query("Upgrade users placed email='', name='New Name' where id='1'");

DELETE

What gets added must eventually get erased. The DELETE query is the easiest query and appears like this:

mysql_query("DELETE FROM users where id='1');

Because entire files are deleted, you don't have to designate a field list. The WHERE clause is vital; without it, all the files in the stand would be removed.

A Scripting Language - can go away SQL questions to the server and display the effect.

A Remote Consumer - a programme on the different machine that can connect to the server and run SQL claims.

You can also use two more indirect methods.

Remote Login - You may be able to hook up to the Server Machine to run one of its local clients.

Web Browser - you may use a browser and scripts that someone has written (we're going to use this method for all of those other workshop).

A person using their web browser requests a active PHP web site, the webserver has been configured to recognise the. php expansion and goes by the record to the PHP interpreter which moves an SQL query to the MySQL server coming back results for PHP to display. You can also use the PHP script to productivity HTML throughout the results to ensure that the results are formatted very well for display inside a browser. It really is vital that the record has a. php expansion or the web server will not know to go it to the interpreter.

More than 7 000 students trust us to do their work
90% of customers place more than 5 orders with us
Special price $5 /page
PLACE AN ORDER
Check the price
for your assignment
FREE