How Does The MySQL Community Work
How Does The MySQL Community Work
How Does The MySQL Community Work
It is the GUI project which can use for any department store where the product is saved by in the
manner of their categories. A category provides the initial class for any product so they can
arranged in a manner for further use. Without a category no new product can be take entry in the
data base. If any category got deleted the product which relates to this category will deleted
automatically from the data base. If any New Entry got effect in the category it will be
automatically available in the product form. This GUI Application is created using PHP, XML
and MySQL.
SYSTEM SPECIFICATION
1. Hardware Requirements
CPU : Core2Duo
COPROCESSOR : BUILT IN
TOTAL RAM : 2 GB
2. Software Requirements
SYSTEM STUDY
INTRODUCTION
solving activity that requires intensive communication between the system users and system
developers. System analysis or study is an important phase of any system development process.
The system is studied to the minutest detail and analyzed. The system analyst plays the role of
the interrogator and dwells deep into the working of the present system. The system is viewed as
a whole and the input to the system are identified. The outputs from the organizations are traced
to the various processes. System analysis is concerned with becoming aware of the problem,
identifying the relevant and decisional variables, analyzing and synthesizing the various factors
A detailed study of the process must be made by various techniques like interviews,
questionnaires etc. The data collected by these sources must be scrutinized to arrive to a
conclusion. The conclusion is an understanding of how the system functions. This system is
called the existing system. Now the existing system is subjected to close study and problem areas
are identified. The designer now functions as a problem solver and tries to sort out the difficulties
that the enterprise faces. The solutions are given as proposals. The proposal is then weighed with
the existing system analytically and the best one is selected. The proposal is presented to the user
for an endorsement by the user. The proposal is reviewed on user request and suitable changes
are made. This is loop that ends as soon as the user is satisfied with proposal.
Preliminary study is the process of gathering and interpreting facts, using the
information for further studies on the system. Preliminary study is problem solving activity that
requires intensive communication between the system users and system developers. It does
various feasibility studies. In these studies a rough figure of the system activities can be
obtained, from which the decision about the strategies to be followed for effective system study
A detailed study of existing system is carried along with all the steps in system analysis. An idea
for creating a better project was carried and the next steps were followed.
FEASIBILITY STUDY
system requested is feasible. Feasibility study is carried out to select the best system that meets
Feasibility study is both necessary and prudent to evaluate the feasibility of the project at the
earliest possible time. It involves preliminary investigation of the project and examines whether
the designed system will be useful to the organization. Months or years of effort, thousand for
The different types of feasibility are: Technical feasibility, Operational feasibility, Economical
feasibility.
1) Technical feasibility
Technology is not a constraint to type system development. We have to find out whether the
necessary technology, the proposed equipments have the capacity to hold the data, which is used
The technical feasibility issues usually raised during the feasibility stage of investigation
includes these
This software is running in windows 2000 Operating System, which can be easily
installed.
2) Operational feasibility
This feasibility test asks if the system will work when it is developed and installed.
The proposed system produces best results and gives high performance. It can be
3) Economical feasibility
Economical Feasibility deals about the economical impact faced by the organization to
implement a new system. Financial benefits must equal or exceed the costs. The cost of
conducting a full system, including software and hardware cost for the class of application being
SOFTWARE DESCRIPTION
PHP is an open-source server-side scripting language we can create dynamic web pages with
the PHP scripting language. A dynamic Web page interacts with the user, so that each user
visiting the page sees customized information. PHP can also be used to create dynamic web
pages that are generated from information accessed from a MySQL database. we can embed PHP
commands within a standard HTML page. PHP's syntax is similar to that of C and Perl, making it
easy to learn for anyone with basic programming skills. Another feature that PHP offers is
connectivity to most of the common databases (including Oracle, Sybase, MySQL, ODBC and
many others, although currently only MySQL is supported on the central webservers.) PHP also
offers integration with various external libraries, which allow the developer to do anything from
LAMP Architecture
• LINUX
• Apache
• MySQL
• PHP
Comments
• Code Commenting
• InLine Commenting
// This is InLine Commenting
• Multiple Line Commenting
/* This is Multiple Line Commenting */
• HTML Comment Tag
<!-- Comments for the HTML and/or PHP go here -->
Construct Feedback
• print()
print("<p>This is the standard use of the print function.</p>");
print "<p>However, the parentheses are not necessary.</p>";
$functionType = "print";
print "<p>Variables can also be included with the $functionType
function.</p>";
print "<p>Another way to add a variable to a ".$functionType.
" function is to concatenate it to the strings</p>";
• echo
echo "<p>This is the standard use of the echo function.</p>";
$functionType = "echo";
echo "<p>The $functionType function can also use embedded
variables.</p>";
echo "<p>When concatenating with the ",$functionType," function,
it is best to use commas to concatenate the strings</p>";
• printf()
printf("<p>%d Euro = $%01.2f US Dollar</p>", 1, 1.3);
printf("<p>My %s paid $%01.2f for my $s</p>","Mother",23.4,
"Dog");
printf("<p>However, my %3\$s paid $%2\$01.2f to get away from my
%1\$s</p>", "Mother", 100.3, "Dog");
printf("<p>%11s</p>", "Long text can be limited to a certain
number of characters, in this case 11.");
• sprintf()
$orderTotal = sprintf("$%01.2f", 123.456);
print "The order total is $orderTotal";
Empty
Empty
Conditional
if ... else if ... else
switch ($variable) { case option 1 ... case option2 ...
default ... }
Iterative
while (expression) { ... }
do { ... } while (expression)
for (expression1, expression2, expression3) { ... }
foreach (array_expression as $value) { ... }
<?php
$i = 5;
while ($i < 5) {
print "$i <br>";
$i = $i + 1;
if ($i > 20000) {
break;
}
}
?>
Designed Specifically for Handling Arrays
and Objects
Two Methods
$value variable
foreach (array_expression as
$value) {
/* statements that execute
until the array
reaches the end or a manual
break is inserted */
}
$key => $value variables
foreach (array_expression as $key
Custom Functions
=> $value) {
Code Reuse is Primary Advantage
/* statements that execute
until the array
Clean Code is a Secondary Advantage
reaches the end or a manual
<?php break is inserted */
}
function circumference
($diameter) {
$c = $diameter * pi();
return(printf("%01.2f",$c));
}
circumference(3); // This would
return 9.42
?>
MySQL Server
Client Programs
MySQL Query Browser
MySQL Administrator
mysql command
line client
Others
mysqlimport,
mysqldump,
mysqladmin,
mysqlcheck
SQL Statements sent from client to server
Executed using a two-tier processing model:
The upper tier includes the SQL parser and optimizer
The lower tier comprises a set of storage engines
The following properties are storage engine
dependant:
Storage Medium
Transactional Capabilities
Locking
Backup and Recovery
Optimization
Special Features
Exclusive Data
Size
Case Sensitivity
SELECT * FROM my_table WHERE
MY_TABLE.col=1;
Character Restrictions
Basic
CREATE DATABASE my_db;
Optional Clauses
CREATE DATABASE my_db CHARACTER SET utf8
COLLATE utf8_danish_ci;
Using the Database
USE my_db;
Displaying Database Structure
mysql> SHOW CREATE DATABASE my_db\G
************************* 1. row
*************************
Database: my_db
Create Database: CREATE DATABASE `my_db`
/*!40100 DEFAULT CHARACTER
SET utf8
COLLATE utf8_danish_ci */
Problems
Insufficient/Incorrect Permissions
Remove a Database
DROP DATABASE my_db;
Table Properties
MyISAM
InnoDB
Memory
NDB
Major Categories
Numeric
TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT
FLOAT, DOUBLE
DECIMAL (NUMERIC)
BIT
String
CHAR, VARCHAR, TINYTEXT, TEXT, MEDIUMTEXT,
LONGTEXT
BINARY, VARBINARY, TINYBLOB, BLOB,
MEDIUMBLOB, LONGBLOB
ENUM, SET
Temporal
DATE, TIME, DATETIME, TIMESTAMP, YEAR
mysql> CREATE TABLE CountryLanguage (
-> CountryCode CHAR(3) NOT NULL,
-> Language CHAR(30) NOT NULL,
-> IsOfficial ENUM('True', 'False') NOT
NULL
-> DEFAULT 'False',
-> Percentage FLOAT(3,1) NOT NULL,
-> PRIMARY KEY(Country, Language)
-> )ENGINE = MyISAM COMMENT='Lists
Language Spoken';
Retreiving Data
• Selecting a Database
– mysql_select_db($db_name, $linkID)
@mysql_select_db($db_name, $link_id) or die("Could not select the $db_name database!");
– mysql_select_db($db_name)
• Querying MySQL
– mysql_query($query, $linkID)
$query_results = mysql_query($query, $link_id);
mysql_query($query)
• Displaying Query Results (1/4)
– mysql_result($query_result, $row_id, $column_name)
$query = "SELECT * FROM world.Country LIMIT 5";
$query_results = mysql_query($query, $linkID1);
for ($count=0; $count <= mysql_numrows($query_results); $count++){
$country_code = mysql_result($query_results, $count, 'Code');
$country_name = mysql_result($query_results, $count, 'Name');
print "$country_name($country_code)<br>\n";
}
– mysql_fetch_array($query_result)
$query = "SELECT Code, Name FROM world.Country LIMIT 10,5";
$query_results = mysql_query($query, $linkID1);
while ($row = mysql_fetch_array($query_results, MYSQL_BOTH)) {
$country_code = $row['Code'];
$country_name = $row['Name'];
print "$country_name($country_code)<br>\n";
}
• MYSQL_ASSOC - $row array would contain only an associative array
• MySQL_NUM - $row array would contain only an index array
– mysql_fetch_object($query_result)
$query = "SELECT Code, Name FROM world.Country";
$query_results = mysql_query($query, $linkID1);
while ($row = mysql_fetch_object($query_results)) {
$country_code = $row->Code;
$country_name = $row->Name;
print "$country_name($country_code)<br>\n";
}
Insert Data
// Insert the data into the City table
$insert_query = "INSERT INTO City SET Name='$CityName',
CountryCode = '$CountryCode',
District='$District',
Population='$Population'";
$insert_result = mysql_query($insert_query,$linkID1);
MySQL Error Information
• PHP offers two functions that can display error messages from MySQL:
– mysql_error() – This function displays the error message (if there was one) from
the last MySQL function
// Insert a record in the INFORMATION_SCHEMA database
$query = "INSERT INTO INFORMATION_SCHEMA.TABLE SET TABLE_NAME = 'dog'";
$query_result = mysql_query($query,$linkID1);
if ($query_result) {
print "<p>INSERT successful</p>";
} else {
print "<p>".mysql_error($linkID1)."</p>";
}
mysql_errno() - This function is identical to the mysql_error() function with the exception that
only the associated error number is displayed without any explanatory text
• PHP stores all the session data associated with a session ID in a single string and handles
the decoding of this string automatically
lname|s:6:"Gordon";fname|s:6:"Jethro";phone|s:10:"7197235674";
• Encoding the Session Variable
// Load the session variables with values
$_SESSION['lname'] = 'Gordon';
$_SESSION['fname'] = 'Jethro';
$_SESSION['phone'] = '7197235674';
// Combine all the session variables together
// into a single string
$session_variables = session_encode();
• Decoding the Session Variable
session_start();
// Obtain the Session ID from the local system
$SID = session_id();
// Read in the encoded session string from MySQL
$linkID1 = mysql_pconnect("localhost", "root", "training");
$session_query = "SELECT sessionVars FROM world.user
WHERE sid = $SID";
$session_result = mysql_query($session_query, $linkID1);
list($session_variables) = mysql_fetch_row($session_result);
session_decode($session_variables);
print "Name: ".$_SESSION['lname'].", ".$_SESSION['fname'];
print " Phone: ".$_SESSION['phone']."<br>\n";
mysql_close($linkID1);
Createdb.php
<?php
$host="localhost";
$username="root";
$password="";
if(!mysql_select_db("ourdb"))
else
?>
In above database will be required almost in every file in this project .so we have
included a special file in all our project file .the special file is given below:
Connction.php
<?php
$host="localhost";
$username="root";
$password="";
$dbname="ourdb";
echo ".";
?>
In this project we have two tables. One table will be used to store categories details
and another to store details of products .the table structures are given below:
tblcatagory
Field Type Null PrimeryKey
cat_id Int(11) Yes Yes
cat_name Varchar(40) Yes No
tblproduct
Createtable.php
<?php
include_once "connection.php";
PRIMARY KEY(cat_id)
);";
PRIMARY KEY(prod_id)
);";
mysql_query($tblproduct) or die(mysql_error());
?>
In our product the first page will provide the user some options like add new
category, display category details, add new product and display product details.
This will be the home page its name will be index.php.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
</head>
<br />
<p align="center">
<br />
<p align="center">
<br />
<p align="center">
</body>
</html>
This is a simple HTML page.
There are some php files used in anchor tag of the above code. These files have
special purpose. This first file in the anchor tage is AddCatagory.php. This file is
used to enter new category. Here is code blow:-
<?php
include_once "connection.php";
$cat_id=stripslashes($_POST['cat_id']);
$cat_name=stripslashes($_POST['cat_name']);
$select_cat="select *from tblcatagory where cat_name='".$cat_name."' or
cat_id='".$cat_id."'";
$select_query=mysql_query($select_cat) or die(mysql_error());
if(mysql_num_rows($select_query)==0)
$insert_query=mysql_query($insert_cat) or die(mysql_error());
if($insert_query)
else
?>
<html>
<head>
<title>Eding Catagory</title>
</head >
<tr><td width="25%">
</tr>
</tr>
</table>
</td><td width="75%"> <form method="post" name="frm1"> <table
width="50%" border="0" cellpadding="0" cellspacing="0" align="center">
</tr> </table><br/><br/>
<table align="center">
</body>
</html>
ScreenShot:-
DisplayCatagories.php
<?php
include_once "connection.php";
{
$cat_id=stripslashes($_POST['cat_id']);
$cat_name=stripslashes($_POST['cat_name']);
$select_query=mysql_query($select_cat) or die(mysql_error());
if(mysql_num_rows($select_query)==0)
$insert_query=mysql_query($insert_cat) or die(mysql_error());
if($insert_query)
}}else{
</tr>
<tr><td align="center"><a href="DisplayCatagories.php"><b
style="color:#000099">Display Catagories</b></a></td></tr><tr><td
align="center"><a href="AddProduct.php"><b style="color:#000099">Add New
Product</b></a></td></tr><tr><td align="center"><a
href="DisplayProduct.php"><b style="color:#000099">Add New
Catagory</b></a></td>
</tr>
<br/><br/>
</body>
</html>
ScreenShot of DisplayCatagotries.php
In this file Anchor tag contains Delete and Edit link where you can go to
editcatagory file where we can edit or delete records.
EditCatagories.php
<?php
include_once "connection.php";
$select_query1=mysql_query($select1) or die(mysql_error());
?>
<html><head><title>Eding Catagory</title>
</tr><tr>
</tr><tr>
</table></td><td width="72%">
<?php
while($data1=mysql_fetch_object($select_query1))
{?> <tr>
</tr></table>
<?php
if(isset($_POST['delete']))
{$con=mysql_connect("localhost","root");
mysql_close($con);
}
else{
$msage="Not submit";}
?>
<tr><td width="100">Catagory_ID</td>
</tr></table></form></body></html>
To add the new product following file is used
Addproduct.php
<?php
include_once "connection.php";
$cat_name=stripslashes(trim($_POST['cat_name']));
$prod_id=stripslashes(trim($_POST['prod_id']));
$prod_name=stripslashes(trim($_POST['prod_name']));
$model=stripslashes(trim($_POST['model']));
$comp_name=stripslashes(trim($_POST['comp_name']));
$prod_dese=$_REQUEST['prod_desc'];
$rate=stripslashes(trim($_POST['rate']));
$select_query2=mysql_query($select_cat2) or die(mysql_error());
$result_cat_id=mysql_fetch_object($select_query2);
$cat_id=$result_cat_id->cat_id;
$insert_product="insert into
tblproduct(prod_id,prod_name,cat_id,comp_name,prod_model,prod_desc,rate)
values
('$prod_id','$prod_name','$cat_id','$comp_name','$model','$prod_dese','$rate')";
$insert_query=mysql_query($insert_product) or die(mysql_error());
if($insert_query)
?>
<html><head>
</tr>
<tr>
</tr><tr>
</tr>
</tr>
</tr></table></td>
<td width="83%">
<form name="frm" method="post" enctype="multipart/form-data">
<tr> <td>Catagory:</td>
<?php
while($catagory_dls=mysql_fetch_object($select_query))
{ ?>
</td></tr>
</tr></table></form></td><tr></table><HR/></body></html>
Displayproduct.php
<?php
include_once "connection.php";
?>
<html>
<head>
<title>Add product</title>
</head >
</table></div>
<tr>
<td width="80">Catagory</td>
<td width="93">CatagoryName</td>
<td width="115">CompnyName</td>
<td width="75">Model</td>
<td width="287">ProductDiscription</td>
<td width="63">Price</td>
<td width="86">Edit</td>
<td width="73">Delete</td>
</tr>
<?php
while ($data=mysql_fetch_object($select_query1))
{
?>
<tr>
<td> <?php
$select_query2=mysql_query($select_cat2) or die(mysql_error());
$result_cat_name=mysql_fetch_object($select_query2);
<td><a href="ProductDelete.php"
style="color:#FF0066"><b>Delete</b></a></td>
</table>
</td>
</tr></table><p><hr/></p> </body></html>
Screen Shot :-
Following is code to edit product where we can se and also delete the records from
table product:-
<html>
<head>
<title>Add product</title>
</head >
</table></div>
<?php //-------------------------------------------------------Delete
catagory--------------------------------------------------------------------------------------
if(isset($_POST['delete']))
$con1=mysql_connect("localhost","root","");
if(! $retval )
mysql_close($con1);
else{
$msage="Not submit";
<td> </td></tr><tr><td>
</tr></table>
</form>
</td><td width="907"><?php
include_once "connection.php";
?>
<tr>
</tr>
<?php
while ($data=mysql_fetch_object($select_query1))
?>
<tr>
<td> <?php
$select_query2=mysql_query($select_cat2) or die(mysql_error());
$result_cat_name=mysql_fetch_object($select_query2);
</table>
</td>
</tr></table>
<table><tr>
<td>
<td>
</tr>
</table>
</body>
</html>