How Does The MySQL Community Work

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 65

ABSTRACT

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

SPEED : 2.5 GHz

COPROCESSOR : BUILT IN

TOTAL RAM : 2 GB

DISKETTE A : 1.44MB FLOPPY 3.5”

HARD DISK : 500 GB

KEYBOARD : 105 KEYS

MOUSE : LOGITECH MOUSE

DISPLAY : SGVA LCD Monitor COLOR

PRINTER : HP DESK JET

2. Software Requirements

FRONT END : PHP 5

BACK END : MySQL 5

OPERATING SYSTEM : WIN XP,VISTA,7

SYSTEM STUDY
INTRODUCTION

System analysis is a process of gathering and interpreting facts, diagnosing

problems and the information to recommend improvements on the system. It is a problem

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

and determining an optimal or at least a satisfactory solution or program of action.

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

and analysis can be taken.

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

An important outcome of the preliminary investigation is the determination that the

system requested is feasible. Feasibility study is carried out to select the best system that meets

the performance requirements.

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

millions of money and untold professional embarrassment can be averted if an in-conceived

system is recognized early in the definition phase.

The different types of feasibility are: Technical feasibility, Operational feasibility, Economical

feasibility.
1) Technical feasibility

Technical Feasibility deals with the hardware as well as software requirements.

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

in the project, should be checked to carryout this technical feasibility.

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.

 The hardware required is Pentium based server.

 The system can be expanded.

2) Operational feasibility

This feasibility test asks if the system will work when it is developed and installed.

Operational feasibility in this project:

 The proposed system offers greater level of user-friendliness.

 The proposed system produces best results and gives high performance. It can be

implemented easily .So this project is operationally feasible.

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

considered should be evaluated.

Economic Feasibility in this project:

 The cost to conduct a full system investigation is possible.

 There is no additional manpower requirement.

 There is no additional cost involved in maintaining the proposed system.

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

generating PDF documents to parsing XML.


How Does the MySQL Community Work

MySQL AB MySQL Community

Open New Ideas


Source
Database
Minimu Code Contributions…
Server
m Two
Binaries/ Bug Reports…
Constant
Year
Source
Fixes/Fe
FreeCode
Mgmt Help, Forums…
atures
Drops
Tools/Conn
ectors
Help, Forums… Spread MySQL Goodwill…

How Does MySQL Enterprise Work?


Community / MySQL MySQL
Third Party Community Server Enterprise Server
Development
Many Ideas / Selected Mature Features
Submissions Submissions Only
Become Features
Design/Develo Community Enterprise
pment Purpose Grade
Community Delivery of Selected Feature
Recommendation Community and Set for Enterprise
s Customer Installations
Community Server Recommendation Predictable
Code s Service Pack
Contributions - Acceptance/Rejec Schedule
Direct tion of Community Strong Internal
Community Code Code Quality Assurance
Contributions – Contributions Testing
MySQL Forge Community External Quality
Third party Testing and Assurance Testing
contributions Validation Certified for
“As Needed” Popular Platforms
Release and Applications
Schedule, Formal Technical
including Bug Support
Fixes and New
Features

MySQL Supported Operating Systems


• More than 20 platforms
• Control and Flexibility for Users
• Currently Available for MySQL Download:
– Windows (multiple)
– Linux (multiple)
– Ubuntu
– Solaris
– FreeBSD
– Mac OS X
– HP-UX
– IBM AIX
– QNX
– Novell NetWare
– SCO
– Open BSD
– SGI Irix
– Source Code
– Special Builds

LAMP Architecture
• LINUX
• Apache
• MySQL
• PHP

Delimiting PHP Code


• PHP Tags
– Default Syntax
<?php ... ?>
– Script Syntax
<script language=“php”> ... </script>
– Short Tags
<? ... ?>
– ASP Style
<% ... %>

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";

PHP Data Types


• Scalar Data Types
– Boolean
– Integer
– Float
– String

• Compound Data Types


– Arrays
– Object

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) { ... }

Three Outcomes (TRUE, FALSE, UNKNOWN)


<?php
$currentDate = date("d-M-Y");
if ($_POST['DateEntered'] >
$currentDate) {
print "That date is in the
future";
} else if ($_POST['DateEntered'] <
$currentDate) {
print "That date is in the
past";
} else {
print "That is today";
}
?>
Anything a switch can do, and if can also do
(and vice-versa)
Interesting Coding Error using Conditional Flow Control
Statements (Can you find the error?)
<?php
switch($annualPay) {
case >= 25000:
$tax_rate = .05;
break;
case >= 50000:
$tax_rate = .10;
break;
case >= 75000:
$tax_rate = .20;
break;
default:
Simplest of all Iterative Control Statements
?>
$tax_rate = .0;

<?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

Enables the sending of queries to the MySQL server


with any results being displayed in the same
interface
Can be used interactively or it can read query input
from a file in batch mode:
Interactive mode is useful for day-to-day usage, for quick
one-time queries, and for testing how queries work
Batch mode is useful for running queries that have been
prewritten and stored in a file
It's especially valuable for issuing a complex series of queries
that's difficult to enter manually, or queries that need to be run
automatically by a job scheduler without user intervention
Semicolon character (‘;’) and the \g sequence:
mysql> SELECT VERSION(), DATABASE();
+-----------------+------------+
| VERSION() | DATABASE() |
+-----------------+------------+
| 4.0.10-beta-log | world |
+-----------------+------------+
\G sequence causes mysql to display query results in a
vertical style that shows each output row with each
column value on a separate line:
mysql> SELECT VERSION(), DATABASE()\G
********************* 1. row
********************
VERSION(): 4.0.10-beta-log
DATABASE(): world
Information Commonality

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;

Its an Error if Database does not Exist:


DROP DATABASE IF EXISTS my_db;
Drop Database Fails
Only Deletes MySQL Associated Files
Other Files not Deleted
Will still show in SHOW DATABASES;
Manually Remove Directory

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';

mysql> SHOW CREATE TABLE CountryLanguage\G


************************ 1. row
************************
Table: CountryLanguage
Create Table: CREATE TABLE
`countrylanguage` (
`Country` 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 DEFAULT CHARSET=latin1
COMMENT='Lists Language Spoken'
1 row in set (#.## sec)
ENGINE={MyISAM | InnoDB | MEMORY}
Indicates the storage engine to be used for the table
MyISAM is the default storage engine (unless --default-storage-
engine has been set)
COMMENT='<comment>'
Up to 60 characters of free form text
CHARACTER SET=<character set>
Specifies the character set for the table
Precede with DEFAULT to assign the default character set
Can be shortened to CHARSET
COLLATE=<collation_name>
Specifies the collation for the table
Add
PrecedeColumns
with DEFAULT to assign the default collation
ALTER TABLE EU_Countries ADD Id INT(6)
NOT NULL;
Remove Columns
ALTER TABLE EU_Countries DROP Id;
Modifying Columns
ALTER TABLE EU_Countries MODIFY
NewPopulation BIGINT(12) NOT NULL;
Changing Columns
ALTER TABLE HeadOfState CHANGE LastName
LastName CHAR(40) NOT NULL;
ALTER TABLE HeadOfState CHANGE LastName
Surname CHAR(40) NOT NULL;
Renaming Tables
ALTER TABLE t1 RENAME TO t2;
RENAME TABLE t1 TO t2;
RENAME TABLE t1 TO tmp, t2 TO t1, tmp
TO t2;
Emptying Tables
DELETE FROM t;
TRUNCATE TABLE t;
DELETE FROM t WHERE status = 'expired'
ORDER BY id
CONNECTION LIMIT
OF MPHP 4;
with MySQL

• Establish and Close a Connection to the MySQL Server from PHP


• Retrieve Data from the MySQL Server
• Insert and Update Data in a MySQL Database Using a PHP Web Form
• Delete MySQL database data with PHP
• Retrieve MySQL Metadata
Retrieve Error Information from MySQL using PHP

• Putting It All Together


<?php
/* Connect to MySQL server */
$linkID1 = @mysql_pconnect('localhost','root','training')
or die("Could not connect to MySQL server");
/* Query the MySQL Server for Information */
$query = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'world'";
$result = mysql_query($query, $linkID1);
while ($row = mysql_fetch_array($result)) {
print $row[0]."<br>";
}
/* Close the connection to the MySQL server */
mysql_close($linkID1);
?>
• As a best practice, it is wise to create a separate PHP script file that would contain
connection variables
• A typical file containing this connection information would look something like the
example below (called connect_info.php):
<?php
// MySQL Server Connection Information
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'training';
?>
<?php
/* Load variable that will be used in mysql_connect */
include "connect_info.php";
/* Connect to MySQL server */
$linkID1 = @mysql_pconnect($dbhost,$dbuser,$dbpass) or
die("Could not connect to MySQL server");
/* Query the MySQL Server for Information */
$query = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'world'";
$result = mysql_query($query, $linkID1);
while ($row = mysql_fetch_array($result)) { print $row[0]."<br>"; }
/* Close the connection to the MySQL server */
mysql_close($linkID1);
?>
• Securing Connection Information
– Operating System Rights
– Remote Connections
– Script Encoding

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";
}

The Web Interface


• The Web Page Script
(1) HTML Head Element
(2) Connecting to the MySQL Server
(3) Looking up the Script
(4) Collected City Information
(5) Displaying the City Results
(6) Close Out HTML Code

Explanation of the Web Page Script


• (1) HTML Head Element
– <html>
– <head></head>
– <title></title>
– <body>
• (2) MySQL Formalities and Update of Data
– include "connect_info.php"
– mysql_connect
mysql_select_db
• (3) Looking up the City
– <form>
• name, type, action
– <input>
• name, type, id, maxlength
– <input type=“submit” ...>
• name, value
• (4) Collecting City Information
– if ($_POST['Submit'] == "Lookup City") {mysql_real_escape_string()
– $lookup_sql
– $lookup_results
list($city_name ...) = mysql_fetch_row($lookup_results)
• (5) Displaying the City Results
– if ($city_Name)
– print <<<END ... END
– <form name="world_update" method="post" action="world_update.php">
– <table ... >
– <input type="text" name="CityName" value="$city_name">
– while ($row = mysql_fetch_array($results, MYSQL_ASSOC))
– <select ...>
– <option ... selected>
– <input type="submit" ... >
• Update City, Delete City, Insert City
• (6) Close out the HTML Code
</body> and </html> tags

Update Existing Data


• Explanation of the New Components in the Web Page Script (world_update.php)
– $_POST['CityCode'], $_POST['CountryCode']... –
– (int)
print "<p><a href=\"world.php\">Return to Main Page</a></p>"
Delete Data
• Explanation of the Additions in the Web Page Script (world_update.php)
– $CityCode = $_POST['CityCode']
$delete_query = "DELETE FROM City WHERE ID=$CityCode”

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

Session Handling Tasks


• Starting a Session
session_start();
• Setting up a Session “Key”
session_start();
// Calling the session ID of the current visitor
echo 'Old session ID :'.session_id();
// Giving the visitor a new session ID
session_id(md5(rand(1,5000)));
echo 'New session ID: '.session_id();
• Replacing the Session “Key”
Remembering the Session
• Replacing the Session “Key”
session_start();
// Calling the session ID of the current visitor
echo 'Old session ID :'.session_id();
// Giving the visitor a new session ID
session_regenerate_id();
echo 'New session ID: '.session_id();
• Remembering the Session
<a href="nextscript.php?<?php echo SID?>">Click here</a>
• Storing the Session Data
$_SESSION['fname'] = 'George';
$_SESSION['lname'] = 'Burnes';

• Retrieving the Session Data


print "Dear ".$_SESSION['fname']." ".$_SESSION['lname'].",";
• Terminating a Session
session_start();
// Unset all session variables
$_SESSION = array();
// Unset all cookie variables
if(isset($_COOKIE[session_name()])){
setcookie(session_name(),'', time()-48000,'/');
}

• 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);

MySQL Handling Logins


• Storing MySQL Session Data
CREATE TABLE `customers` (
`customerEmail` VARCHAR(40) NOT NULL,
`lname` VARCHAR(25) NOT NULL,
`fname` VARCHAR(25) NOT NULL,
`title` ENUM('Mr.', 'Mrs.', 'Miss', 'Ms.', 'Dr.');
`password` VARCHAR(30),
PRIMARY KEY (`customerEmail`)
);

• Creating a Login Form


<p>
<form name="login" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
E-mail assigned to the account: <input type="input" name="email"
size="40"><br>\n
Password: <input type="password" name="pswd"><br>\n
<input type="submit" value="Login">
</form>
</p>

Managing the Login Process


(1) HTML Head Element
(2) Standard Opening Sequence for PHP Scripts using Session Handling and MySQL
(3) Session Information has already been loaded, which shows a prior successful login
• $_SESSION['email']
• $welcome_SQL
(4) Session Information has not been loaded, check to see if login form has been submitted
SHA($postPass)
• Managing the Login Process (Continued)
(5) Test to See if the Login Name and Password Match the Data Stored in MySQL
• mysql_numrows($login_results) == 1
• $_SESSION['email'] = $postEmail
• include "login.html"
(6) If There is No Session Handler for the Email and The Login Form has not been Submitted
(7) HTML Footer Information

• Public, Private, Protected, Static


• Working with classes
• Example
class Dog {
public $furColor; // Anyone can see the dog's color
private $age; // The dog's age is not immediately obvious
// Only the dog can decide to run
private function Run() { /* Code */ }
// Anyone can pet the dog
public function Pet() { /* Code */ }
// dog not needed to find out about local breeds
public static function getLocalBreeds() { /* Code */ }
}
$myCanine = new Dog();
$myCanine->furColor = 'brown'; /* Dye our dog's fur */
$myCanine->Pet();
$myCanine->Run(); /* Illegal - Private method */
echo $myCanine->age; /* Illegal - Private property */
$breeds = Dog::getLocalBreeds();
• Method Declarations
• Instantiate a Class
• Accessing Public Properties and Methods
$myCanine->furColor = 'brown';
$myCanine->Pet();
• Accessing Private Properties and Methods
$myCanine->Run(); /* Illegal - Private method */
echo $myCanine->age; /* Illegal - Private property */
• Get and Set Functions
– getAge()
– getColor()
– dyeFur()
• Informational Functions
getLocalBreeds()

Types of HTTP Authentication


Basic Authentication
Digest Authentication
Authentication Variables
$_SERVER['PHP_AUTH_USER']
$_SERVER['PHP_AUTH_PW']
Limitations of Authentication Variables
Both variables must be verified at the start of every page
The functions do not work properly with the CGI version
of PHP
These functions do not work on Microsoft's IIS server -
the username and password are assigned to the
$_SERVER['HTTP_AUTHENTICATION'] variable
and must be parsed to obtain the separate username and
password
This is the simplest PHP authentication to
implement but has the problem of being limited on
flexibility and high on maintenance cost
<?php
if (($_SERVER['PHP_AUTH_USER'] != 'root') ||
($_SERVER['PHP_AUTH_PW'] != 'training'))
{
header('WWW-authenticate: Basic
Realm="Photo Album"');
header('HTTP/1.0 401 Unauthorized');
print "You must provide a valid username
and password!";
exit;
}
// Remainder of script
?>
Limitations of Hard-Coding
Using the same username
CODE
In this GUI project we will see how a data base is manipulated using PHP. First we
have to make a database. IN this project the name of the data base is “ ourdb ” .
we can create the database using the following program:

Createdb.php

<?php

$host="localhost";

$username="root";

$password="";

mysql_connect($host,$username,$password) or die("Sorry could not connect");

if(!mysql_select_db("ourdb"))

$createdb="CREATE DATABASE ourdb";

mysql_query($createdb) or die ("Can't create database ");

echo "Database created";

else

echo "database already exist";

?>

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";

$conect=mysql_connect($host,$username,$password) or die("Can't connect to the


server database chek password and username");

mysql_select_db(s are fiven below:cture$dbname,$conect) or die("can't find


database");

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

prod_id Int(11) Yes Yes

prod_name varchar(250) Yes No

cat_id Int(11) Yes No


comp_name Varchar(40) Yes No

model Varchar(20) Yes No

prod_desc Varchar(255) Yes No

rate Varchar(float) Yes No

To create table here is the code:

Createtable.php

<?php

echo "W r creating table..........connecting.......... connecting............";

include_once "connection.php";

$tblcatagory="CREATE TABLE tblcatagory

cat_id int(11) NOT NULL,

cat_name varchar(40) NOT NULL,

PRIMARY KEY(cat_id)

);";

mysql_query($tblcatagory) or die (mysql_error());

echo "created table tblcatagory......now second table...................<br/>...............";

$tblproduct="CREATE TABLE tblproduct(

prod_id int(11) NOT NULL,

prod_name varchar(140) NOT NULL,


cat_id int(11) NOT NULL,

comp_name varchar (40) NOT NULL,

prod_model varchar(20) NOT NULL,

prod_desc varchar(255) NOT NULL,

rate float NOT NULL,

PRIMARY KEY(prod_id)

);";

mysql_query($tblproduct) or die(mysql_error());

echo "...........successfully created";

?>

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.

Here the code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

</head>

<body bgcolor="#BBE8B0" style="font-size:18px;"><br /><br /><br />


<table width="1140" height="433" align="center" bgcolor="#0066CC">

<tr><td width="1132" height="393">

<h1 align="center" style="background-color:#44174f; color:#FFFFFF">Select


Any Option</h1>

<br />

<fieldset class="style1" style=" background-color:#0099FF" >

<legend> <span class="style4"><b>Select Your Operation</b></span>: </legend


>

<p align="center">

<a href="AddCatagory.php"><font style="color:#FFFFFf"><b>Add New


Catagory</b></font></a> </p>

<br />

<p align="center">

<a href="DisplayCatagories.Php"><font style="color:#FFFFFF"><b>Display all


Catagory</b></font></a></p>

<br />

<p align="center">

<a href="AddProduct.php"><font style="color:#FFFFFF"><b>Add New


Product</b></font></a></font></p>

<br /><p align="center">

<a href="DisplayProduct.php"><font style="color:#FFFFFF"><b>Display


Product</b></font></a></p><br /></fieldset></td></tr></table>

</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";

if(isset($_POST['Add']) && $_POST['Add']=='Add Catagory')

if($_POST['cat_id']!='' && $_POST['cat_name']!='')

$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_cat="insert into tblcatagory(cat_id,cat_name) values($cat_id,'$cat_name')";

$insert_query=mysql_query($insert_cat) or die(mysql_error());

if($insert_query)

$msg="CONGRATE new catagory has been addid!!";

else

$msg="<h2>CAUTION..CAUTION catagory Id o-r name already has been addid!!


</h2>";}

?>

<html>

<head>

<title>Eding Catagory</title>
</head >

<body bgcolor="#006699" text="#FFFFFF">

<H1 align="center">Add New </H1>

<hr align="center" size="3" color="white" width="100%"/>

<p align="center"><?php echo $msg;?></p>

<table align="center" width="100%" border="0">

<tr><td width="25%">

<table border="0" bgcolor="#33CC33" width="98%" >

<tr><td align="center"><a href="AddCatagory.php"><b


style="color:#000099">Add New Catagory</b></a></td>

</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>

<tr><td align="center"><a href="Index.php"


style="color:#ff0000"><b>MainPage</b></a></td>

</tr>

</table>
</td><td width="75%"> <form method="post" name="frm1"> <table
width="50%" border="0" cellpadding="0" cellspacing="0" align="center">

<tr> <td width="50%" align="left" style="font-size:20px"><b>Catagory Id:</b>


</td> <td width="50%" align="left"><input type="text" maxlength="50"
name="cat_id"/></td> </tr>

<tr> <td width="50%" align="left" style="font-size:20px"><b>Catagory


Name:</b> </td>

<td width="50%" align="left" style="font-size:20px"><input


type="text" maxlength="50" name="cat_name"/> </td>

</tr> </table><br/><br/>

<table align="center"><tr><td align="center"><input type="submit" name="Add"


style="color:#CC0033" value="Add Catagory"/></td></tr></table> </form>
</td></tr></table><br>

<table align="center">

<tr><td><hr align="center" style="border:4px;


width:1200px"/></td></tr></table>

</body>

</html>
ScreenShot:-

Next file is used to display the list of categories stored in tblcatagories.

DisplayCatagories.php

<?php

include_once "connection.php";

if(isset($_POST['Add']) && $_POST['Add']=='Add Catagory')

if($_POST['cat_id']!='' && $_POST['cat_name']!='')

{
$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_cat="insert into tblcatagory(cat_id,cat_name) values($cat_id,'$cat_name')";

$insert_query=mysql_query($insert_cat) or die(mysql_error());

if($insert_query)

{$msg="CONGRATE new catagory has been addid!!";

}}else{

$msg="<h2>CAUTION..CAUTION catagory Id o-r name already has been addid!!


</h2>";}}}?>

<html><head><title>Eding Catagory</title></head >

<body bgcolor="#006699" text="#FFFFFF">

<H1 align="center">Add New </H1>

<hr align="center" size="3" color="white" width="100%"/>

<p align="center"><?php echo $msg;?></p>

<table align="center" width="100%" border="0">

<tr><td width="25%"><table border="0" bgcolor="#33CC33" width="98%" >

<tr><td align="center"><a href="AddCatagory.php"><b


style="color:#000099">Add New Catagory</b></a></td>

</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>

<tr><td align="center"><a href="Index.php"


style="color:#ff0000"><b>MainPage</b></a></td></tr></table></td>

<td width="75%"> <form method="post" name="frm1"> <table width="50%"


border="0" cellpadding="0" cellspacing="0" align="center"> <tr>

<td width="50%" align="left" style="font-size:20px"><b>Catagory Id:</b> </td>


<td width="50%" align="left"><input type="text"
maxlength="50" name="cat_id"/></td></tr>

<tr> <td width="50%" align="left" style="font-size:20px"><b>Catagory


Name:</b> </td>

<td width="50%" align="left" style="font-size:20px"><input type="text"


maxlength="50" name="cat_name"/> </td> </tr> </table>

<br/><br/>

<table align="center"><tr><td align="center"><input type="submit" name="Add"


style="color:#CC0033" value="Add Catagory"/></td></tr></table>

</form> </td></tr></table><br> <table align="center">

<tr><td><hr align="center" style="border:4px; idth:1200px"/></td></tr></table>

</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";

$select1="select *from tblcatagory";

$select_query1=mysql_query($select1) or die(mysql_error());
?>

<html><head><title>Eding Catagory</title>

</head ><body bgcolor="#006699" text="#FFFFFF">

<H1 align="center">Add New </H1>

<hr align="center" size="4" color="white" width="100%"/>

<p align="center"><?php echo $msg;?></p>

<table align="center" width="100%" border="0"><tr><td width="28%">

<table border="0"; style=" background-color: #009900; border: 1px none


#000000;" bgcolor="#00CCFF" width="98%" >

<tr><td align="center"><a href="AddCatagory.php"><font color="#FFFFFF">


<b>Add New Catagory</b></font></a></td>

</tr><tr>

<td align="center"><a href="DisplayCatagories.php"><font


color="#FFFFFF"><b>Display Catagories</b></font></a></td>

</tr><tr>

<td align="center"><a href="AddProduct.php"><font color="#FFFFFF">

<b>Add New Product</b></font></a></td>

</tr><tr><td align="center"><a href="DisplayProduct.php"><font


color="#FFFFFF"><b>Display Product</b></font></a></td>

</tr><tr><td align="center" bgcolor="#0099FF"><a href="Index.php"


style="color:#ff0000"><font
color="#FFFFFF"><b>MainPage</b></font></a></td></tr>

</table></td><td width="72%">

<table width="100%" border="1">

<tr><td width="36%" height="24">Catagory name</td>

<td width="29%">Edit</td><td width="35%">Delete</td>


</tr></table><table width="880" border="1">

<?php

while($data1=mysql_fetch_object($select_query1))

{?> <tr>

<td width="36%" height="27"><?php echo $data1->cat_id ?></td>

<td width="29%"> <?php echo $data1->cat_name ?> </td>

<td width="35%"></a><a href="EditCatagories.php">Delete</a></td>

</tr> <?php }?></table></td>

</tr></table>

<?php

if(isset($_POST['delete']))

{$con=mysql_connect("localhost","root");

mysql_select_db("ourdb",$con)or die("can not select database or database doest


exist");$cat_id = $_POST['cat_id'];

$sql = "DELETE from tblcatagory WHERE cat_id ='".$cat_id."'" ;

$sql1 = "DELETE from tblproduct WHERE cat_id ='".$cat_id."'" ;

$retval = mysql_query( $sql1, $con );

$retval1 = mysql_query( $sql, $con );

if(! $retval1 && ! $retval )

{ die('Could not delete data: ' . mysql_error());

}$msage="Deleted data successfully\n"."<a href=DisplayCatagories.php>Refresh-


Now</a>";

mysql_close($con);

}
else{

$msage="Not submit";}

?>

<form method="post" action="<?php $_PHP_SELF ?>">

<table width="400" border="0" align="center" cellspacing="1" cellpadding="2">

<tr><td width="100">Catagory_ID</td>

<td><input name="cat_id" type="text" id="cat_id"></td>

</tr><tr><td width="100"> </td><td> </td></tr><tr><td>

<input name="delete" type="submit" id="delete" value="Delete">

</td><td width="100"><?php echo $msage;?> </td>

</tr></table></form></body></html>
To add the new product following file is used

Addproduct.php

<?php

include_once "connection.php";

$select_cat="select * from tblcatagory";

$select_query=mysql_query($select_cat) or die (mysql_error());

if (isset($_POST['Add'])&& ($_POST['Add']=='Add Product'))

if($_POST['cat_name']!='select' && $_POST['comp_name']!='' &&


$_POST['model']!='' && $_POST['prod_desc']!='' && $_POST['rate']!='')

$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_cat2="select cat_id from tblcatagory where cat_name='".$cat_name."'";

$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)

echo "new product detail added!!";

else{ $msg="Model no can't be quniqe!!";}

?>

<html><head>

<title>Add product</title></head >

<body bgcolor="#0066FF" text="#FFFFFF">


<H1 align="center">Add New </H1>

<hr align="center" size="4" width="100%"/>

<p align="center"><?php echo $msg;?></p>

<table align="center" width="100%" border="0">

<tr><td width="17%"><table border="0" style="position:absolute; left: 25px; top:


133px; width: 186px; height: 115px; background-color: #009900; border: 1px none
#000000;" bgcolor="#00CCFF" width="98%" >

<tr><td align="center"><a href="AddCatagory.php"><font color="#FFFFFF">


<b>Add New Catagory</b></font></a></td>

</tr>

<tr>

<td align="center"><a href="DisplayCatagories.php"><font


color="#FFFFFF"><b>Display Catagories</b></font></a></td>

</tr><tr>

<td align="center"><a href="AddProduct.php"><font color="#FFFFFF"><b>Add


New Product</b></font></a></td>

</tr>

<tr><td align="center"><a href="DisplayProduct.php"><font


color="#FFFFFF"><b>Display Product</b></font></a></td>

</tr>

<tr><td align="center" bgcolor="#0099FF"><a href="Index.php"


style="color:#ff0000"><font
color="#FFFFFF"><b>MainPage</b></font></a></td>

</tr></table></td>

<td width="83%">
<form name="frm" method="post" enctype="multipart/form-data">

<table width="606" border="0" align="center" cellspacing="5">

<tr> <td>Product Id:</td><td><input type="text" name="prod_id"/></td>

</tr><tr> <td>Product Name:</td><td><input type="text"


name="prod_name"/></td></tr>

<tr> <td>Catagory:</td>

<td width="282"><select name="cat_name">

<?php

while($catagory_dls=mysql_fetch_object($select_query))

{ ?>

<option value="<?php echo $catagory_dls->cat_name ?>">

<?php echo $catagory_dls->cat_name?>

</option> <?php }?> </select>

</td></tr>

<tr> <td>Companay Name:</td><td><input type="text"


name="comp_name"/></td></tr>

<tr> <td>Model :</td><td><input type="text" name="model"/></td></tr>

<tr> <td>Discription:</td><td><textarea rows="5" cols="40" name="prod_desc"


></textarea></td>

</tr><tr> <td>Rate:</td><td><input type="text" name="rate"/></td></tr>

</table><table width="564" border="0" align="center" cellspacing="5">

<tr><td align="center"> <input type="submit" name="Add" value="Add


Product"/></td>

</tr></table></form></td><tr></table><HR/></body></html>

Here is screen Shot :


Following will be used to see the record stored in the table “tblproduct”

Displayproduct.php

<?php

include_once "connection.php";

if(isset($_GET['delete']) && $_GET['Delete']=='yes')

$delete_query="delete from tblproduct where prod_id='".$_GET['cat_id']."'";

mysql_query($delete_query) or die (mysql_error());


}

$select1="select *from tblproduct";

$select_query1=mysql_query($select1) or die (mysql_error());

?>

<html>

<head>

<title>Add product</title>

</head >

<body bgcolor="#0066FF" text="#FFFFFF">

<H1 style="position:absolute; left: 40px; top: 70px; width: 132px; margin:1,1,1,1;


height: 34px;" align="center"><u>Option&gt;&gt;</u></H1>

<H1 style="position:absolute; left: 449px; top: 114px; margin-bottom:2px; width:


333px; height: 30px;" align="center">All Record in DataBase </H1>

<div style="position:absolute; width: 1038px; left: 192px; top: 74px; height:


26px;">

<table border="0" bgcolor="#00CC66" width="100%" >

<tr><td height="28" align="center"><a href="AddCatagory.php"><font


color="#0000cc"><b>Add New Catagory</b></font></a></td>

<td align="center"><a href="DisplayCatagories.php"><font


color="#0000cc"><b>Display Catagories</b></font></a></td>
<td align="center"><a href="AddProduct.php"><font color="#0000cc"><b>Add
New Product</b></font></a></td> <td align="center"><a
href="DisplayProduct.php"><font color="#0000cc"><b>Display
Product</b></font></a></td><td align="center"><a href="Index.php"
style="color:#ff0000"><b>MainPage</b></a></td></tr>

</table></div>

<div style="position:absolute; width: 349px; left: 844px; top: 124px; height:


21px;">

<p align="center"><?php echo $msg;?></p></div>

<table style="position:absolute; left: 26px; top: 166px; height: 74px;"


align="center" width="100%" border="0">

<tr><td width="125" height="80"></td><td width="1096">

<table width="1028" height="59" border="1px">

<tr>

<td width="85" height="23">ProductName</td>

<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))
{

?>

<input type="hidden" name="prod_id" value="" />

<tr>

<td width="85" height="28"><?php echo $data->prod_name ?></td>

<td width="80"><?php echo $data->cat_id ?></td>

<td> <?php

$select_cat2="select * from tblcatagory where cat_id='".$data->cat_id."'";

$select_query2=mysql_query($select_cat2) or die(mysql_error());

$result_cat_name=mysql_fetch_object($select_query2);

echo $result_cat_name->cat_name ?></td>

<td><?php echo $data->comp_name ?></td>

<td width="75"><?php echo $data->prod_model ?></td>

<td width="287"><?php echo $data->prod_desc ?></td>

<td width="63"><?php echo $data->rate ?></td>

<td><a href="ProductDelete.php" style="color:#ff0000"><b>Edit</b></a></td>

<td><a href="ProductDelete.php"
style="color:#FF0066"><b>Delete</b></a></td>

</tr> <?php } ?>

</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 >

<body bgcolor="#0066FF" text="#FFFFFF">

<H1 style="position:absolute; left: 448px; top: 113px; width: 333px; height:


30px;" align="center">All Record in DataBase </H1>

<H1 style="position:absolute; left: 21px; top: 74px; width: 139px;"


align="center">Option&gt;&gt;</H1>

<div style="position:absolute; width: 1038px; left: 165px; top: 74px; height:


26px;">
<table border="0" bgcolor="#00CC66" width="100%" >

<tr><td height="28" align="center"><a href="AddCatagory.php"><b>Add New


Catagory</b></a></td>

<td align="center"><a href="DisplayCatagories.php"><b>Display


Catagories</b></a></td>

<td align="center"><a href="AddProduct.php"><b>Add New


Product</b></a></td>

<td align="center"><a href="DisplayProduct.php"><b>Display


Product</b></a></td>

<td align="center"><a href="Index.php"


style="color:#ff0000"><b>MainPage</b></a></td></tr>

</table></div>

<div style="position:absolute; width: 349px; left: 844px; top: 124px; height:


21px;"><p align="center"><?php echo $msg;?></p>

</div><table style="position:absolute; left: 26px; top: 156px; height: 80px; width:


1181px;" align="center" width="100%" border="0">

<tr><td width="264" height="80">

<?php //-------------------------------------------------------Delete
catagory--------------------------------------------------------------------------------------

if(isset($_POST['delete']))

$con1=mysql_connect("localhost","root","");

mysql_select_db("ourdb",$con1)or die("can not select database or database doest


exist");
$prod_id = $_POST['prod_id'];

$sql1 = "DELETE from tblproduct WHERE prod_id ='".$prod_id."'" ;

$retval = mysql_query( $sql1, $con1 );

if(! $retval )

die('Could not delete data: ' . mysql_error());}

$msage="Deleted data successfully\n"."<a href=ProductDelete.php>Refresh-


Now</a>";

mysql_close($con1);

else{

$msage="Not submit";

}?><form method="post" action="<?php $_PHP_SELF ?>">

<table width="276" border="0" style="position:absolute; left: 6px; top: 13px;"


align="center" cellspacing="1" cellpadding="2">

<tr><td width="118">Product ID</td>

<td><input name="prod_id" type="text" size="14px" id="prod_id"></td>

</tr><tr><td width="118"> </td>

<td> </td></tr><tr><td>

<input name="delete" type="submit" id="delete" value="Delete">

</td><td width="147"><?php echo $msage;?> </td>

</tr></table>

</form>

</td><td width="907"><?php
include_once "connection.php";

$select1="select *from tblproduct";

$select_query1=mysql_query($select1) or die (mysql_error());

?>

<table width="900px" align="right" height="59" border="1px">

<tr>

<td width="73" height="17"><b style="color:#00FF00">ProductId</b></td>

<td width="87" height="17"><b style="color:#00FF00">ProductName</b></td>

<td width="71" ><b style="color:#00FF00">Catagory</b></td>

<td width="95"><b style="color:#00FF00">CatagoryName</b></td>

<td width="93"><b style="color:#00FF00">CompnyName</b></td>

<td width="62"><b style="color:#00FF00">Model</b></td>

<td width="291"><b style="color:#00FF00">ProductDiscription</b></td>

<td width="76"><b style="color:#00FF00">Price</b></td>

</tr>

<?php

while ($data=mysql_fetch_object($select_query1))

?>

<tr>

<td width="73" height="28"><?php echo $data->prod_id ?></td>

<td width="87" height="28"><?php echo $data->prod_name ?></td>


<td width="71"><?php echo $data->cat_id ?></td>

<td> <?php

$select_cat2="select * from tblcatagory where cat_id='".$data->cat_id."'";

$select_query2=mysql_query($select_cat2) or die(mysql_error());

$result_cat_name=mysql_fetch_object($select_query2);

echo $result_cat_name->cat_name ?></td>

<td><?php echo $data->comp_name ?></td>

<td width="62"><?php echo $data->prod_model ?></td>

<td width="291"><?php echo $data->prod_desc ?></td>

<td width="76"><?php echo $data->rate ?></td>

</tr> <?php } ?>

</table>

</td>

</tr></table>

<table><tr>

<td>

<hr style="position:absolute; width:1200px; left: 26px; top: 533px;"/>

<td>

</tr>

</table>

</body>

</html>

Here is Screen Shot

You might also like