Object oriented Programming Practice for including all database connectivity insert,update ,delete ,display code all in one in a single page :

Object oriented Programming Practice for including all database connectivity insert,update ,delete ,display code all in one in a single page : - Hallo sahabat Tutorials, Pada Artikel yang anda baca kali ini dengan judul Object oriented Programming Practice for including all database connectivity insert,update ,delete ,display code all in one in a single page :, kami telah mempersiapkan artikel ini dengan baik untuk anda baca dan ambil informasi didalamnya. mudah-mudahan isi postingan yang kami tulis ini dapat anda pahami. baiklah, selamat membaca.

Judul : Object oriented Programming Practice for including all database connectivity insert,update ,delete ,display code all in one in a single page :
link : Object oriented Programming Practice for including all database connectivity insert,update ,delete ,display code all in one in a single page :

Baca juga


Object oriented Programming Practice for including all database connectivity insert,update ,delete ,display code all in one in a single page :


Object oriented Programming Practice for   including all database connectivity  insert,update ,delete ,display code all in one in a single page  :

First  create   table  record:
step 1: create table  record
(id  int primary key  auto_increment,
name  varchar(200),
city varchar(200)
);

(1)write code for  All_model.php file:
<?php
class All_model
{
var $servername="localhost";
var $username="root";
var $pwd="";
var $dbname="prakash";
var $con;

function __construct()
{
$this->con=new mysqli($this->servername,$this->username,$this->pwd,$this->dbname);
if($this->con->connect_error)
{
die ("connection failed:".$con->connect_error);
}

}

function insert($a,$b,$c)
{
$sql="insert into record(id,name,city)values('$a','$b','$c')";
$res=$this->con->query($sql);

if($res)
{
echo "inserted";
}
else
{
echo "not inserted";
}
$this->con->close();
}

function update($a,$b,$c)
{
$sql="update record set name='$b', city='$c' where id='$a'";
$res=$this->con->query($sql);

if($res)
{
echo "updated";
}
else
{
echo "not updated";
}
$this->con->close();
}

function delete($a)
{
$sql="delete from record where id='$a'";
$res=$this->con->query($sql);

if($res)
{
echo "deleted";
}
else
{
echo "not deleted";
}
$this->con->close();
}

function  search($name)
{
$sql = "SELECT * FROM  record where name='$name'";
$result = $this->con->query($sql);

if ($result->num_rows > 0) 
{
    // output data of each row

    while($row = $result->fetch_assoc()) 
{
        echo "id: " . $row["id"]. "  Name: " . $row["name"]. " " . $row["city"]. "<br>";
    }

else 
{
    echo "0 results";
}

$this->con->close(); //connection close
}

function  displayall()
{
$sql = "SELECT * FROM  record";
$result = $this->con->query($sql);

if ($result->num_rows > 0) 
{
    // output data of each row

    while($row = $result->fetch_assoc()) 
{
        echo "id: " . $row["id"]. " - Name: " . $row["name"]. " " . $row["city"]. "<br>";
    }

else 
{
    echo "0 results";
}

$this->con->close(); //connection close
}

}
$obj=new All_model();




?>

=================insert data================
(1)insert.html file code:
<form action="insert.php" method="post">
id<input type="text" name="id">
name<input type="text" name="name">
city<input type="text" name="city">
<input type="submit" name="submit" value="insert">

</form>

(2)insert.php file code:
<?php
include('All_model.php');
$id=$_POST['id'];
$name=$_POST['name'];
$city=$_POST['city'];
$obj->insert($id,$name,$city);

?>

=================update data===========
(1)update.html file code:
<form action="update.php" method="post">
id<input type="text" name="id">
name<input type="text" name="name">
city<input type="text" name="city">
<input type="submit" name="submit" value="update">

</form>

(2)update.php file code :
<?php
include('All_model.php');
$id=$_POST['id'];
$name=$_POST['name'];
$city=$_POST['city'];
$obj->update($id,$name,$city);

?>

==================delete==data =======================
(1)write  delete.html file:
<form action="delete.php" method="post">
id<input type="text" name="id">

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

</form>

(2)write delete.php file:

<?php
include('All_model.php');
$id=$_POST['id'];

$obj->delete($id);

?>

======================search example=====================
(1)write  search.html file:
<form action="search.php" method="post">
name<input type="text" name="name">

<input type="submit" name="submit" value="search">

</form>

(2)write search.php file code:

<?php
include('All_model.php');
$name=$_POST['name'];

$obj->search($name);

?>































(1)write  code all.php   file:

<?php
                class all
                {
                var $host='localhost';
                var $rt='root';
                var $pw='';
                var $database='manasi';
                var $con;
               
                function  __construct()
                {
                                $this->con=mysql_connect($this->host,$this->rt,$this->pw);
                                if($this->con)
                                {
                                                echo "Connection successful";
                                }
                                else
                                {
                                                echo "Connection failed";
                                }
                                mysql_select_db($this->database,$this->con);
                }
               
                                function myinsert()
                                {
                                                if(isset($_POST['insert']))
                                                {
                                                                $id=$_POST['id'];
                                                                $name=$_POST['name'];
                                                                $sql="insert into myprofile(id,name) values('$id','$name')";
                                                                mysql_query($sql);
                                                                echo "Record inserted successfully";
                                                }
                                }
                                function myupdate()
                                {
                                                if(isset($_POST['update']))
                                                {
                                                                $id=$_POST['id'];
                                                                $name=$_POST['name'];
                                                                $sql="update myprofile set name='$name' where id='$id'";
                                                                mysql_query($sql);
                                                                echo "Record updated successfully";
                                                }
                                               
                                }
                                function mydelete()
                                {
                                                if(isset($_POST['delete']))
                                                {
                                                                $id=$_POST['id'];
                                                                $sql="delete from myprofile where id='$id'";
                                                                mysql_query($sql);
                                                                echo "Record deleted successfully";
                                                }
                                               
                                }
                                function mysearch()
                                {
                                                if(isset($_POST['search']))
                                                {
                                                                $id=$_POST['id'];
                                                                $sql="select * from myprofile where id='$id'";
                                                                $result=mysql_query($sql);
                                                                echo '<table border=2>
                                                                                                <tr>
                                                                                                                <td>Id</td>
                                                                                                                <td>Name</td>
                                                                                                </tr>';
                                                                while($row=mysql_fetch_array($result))
                                                                {
                                                                                echo '<tr>';
                                                                                                echo '<td>';
                                                                                                                echo $row['id'];
                                                                                                echo '</td>';
                                                                                                echo '<td>';
                                                                                                                echo $row['name'];
                                                                                                echo '</td>';
                                                                                echo '</tr>';
                                                                }
                                                                echo '</table>';
                                                }
                                               
                                }
                }
                $allinone=new all();
?>

(2)now how to use all.php file for insert:

(a)write code for  insert.html  file:
<form action="allinsert.php" method=post>
                Id<input type=text name=id>
                Name<input tpye=text name=name>
                <input type=submit name=insert value=Insert>
</form>
(b)now write code for   allinsert.php file:
<?php
                include("all.php");
                $allinone->myinsert();
?>
(3)Now   write   code  how to use all.php   file   for update:
(a)write code for update.html file:
<form action="allupdate.php" method=post>
                Id<input type=text name=id>
                Name<input tpye=text name=name>
                <input type=submit name=update value=Update>
</form>
(b)now   write   code   for   allupdate.php  file:
<?php
                include("all.php");
                $allinone->myupdate();
?>

(4)Now write code for  how to use all.php file to delete record:

(a)write code for delete.html file:
<form action="alldelete.php" method=post>
                Id<input type=text name=id>
                <input type=submit name=delete value=Delete>
</form>
(b)Now   write code for alldelete.php file:
<?php
                include("all.php");
                $allinone->mydelete();
?>

(5)Now  write  code for how to use all.php file for search record:

(a)write  code for search.html file :
<form action="allsearch.php" method=post>
                Id<input type=text name=id>
                <input type=submit name=search value=Search>
</form>
(b)now   write code for   allsearch.php file:
<?php
                include("all.php");
                $allinone->mysearch();
?>

========================================================================
RIGHT AND PERFECT OBJECT ORIENTED TECHNIQUES 
========================================================================
(1)FIRST OF create table about:
SQL>
create table about
(id  int primary key auto_increment,
pagetitle  varchar(200),
description varchar(200),
keyword  varchar(200),
editor1  varchar(200)
);

(2)write code for  database.php file :
<?php
class DBController
{
 private $host = "localhost";
 private $user = "root";
 private $password = "";
 private $database = "test";

 function __construct()
 {
  $conn = $this->connectDB();

  if(!empty($conn))
  {
   $this->selectDB($conn);
  }

 }

 function connectDB()
 {
  $conn = mysql_connect($this->host,$this->user,$this->password);
  return $conn;
 }

 function selectDB($conn)
 {
  mysql_select_db($this->database,$conn);
 }

 function displayQuery($query)//this function is for display record and for search query
 {
  $result = mysql_query($query);
  while($row=mysql_fetch_assoc($result)) {
   $resultset[] = $row;
  }
  if(!empty($resultset))
   return $resultset;
 }

 function runQuery($query) // this function is for insert,update,delete query
 {
$result = mysql_query($query);
return $result;
 }

 function numRows($query)
 {
  $result  = mysql_query($query);
  $rowcount = mysql_num_rows($result);
  return $rowcount;
 }
}
?>

========================================================================
INSERT  QUERY USING OBJECT ORIENTED
========================================================================

(1)write  code  for insert.html file:
<form action="insert.php"  method="post">
Page title<input type=text name=pagetitle>
description <input type=text name=description>
keyword <input type=text name=keyword>
editor1 <input type=text name=editor1>
<input type=submit name=insert  value=insert>
</form>

(2)write code for insert.php file:
<?php

include('database.php');

$pagetitle=$_POST['pagetitle'];
$description=$_POST['description'];
$keyword=$_POST['keyword'];
$editor1=$_POST['editor1'];

$query="insert into about(pagetitle,description,keyword,editor1)values('$pagetitle','$description','$keyword','$editor1')";

$obj=new DBController();

$result=$obj->runQuery($query);

if($result)
{

echo "record inserted";
}
else
{
echo "not inserted";
}
?>

========================================================================
UPDATE  QUERY USING OBJECT ORIENTED
========================================================================

(1)Write code for  update.html file:
<form action="update.php"  method="post">
Page title<input type=text name=pagetitle>
description <input type=text name=description>
keyword <input type=text name=keyword>
editor1 <input type=text name=editor1>
<input type=submit name=update  value=update>
</form>

(2)write code  for update.php file:

<?php

include('database.php');

$pagetitle=$_POST['pagetitle'];
$description=$_POST['description'];
$keyword=$_POST['keyword'];
$editor1=$_POST['editor1'];

$query="update  about set  pagetitle='$pagetitle',description='$description',keyword='$keyword',editor1='$editor1' where pagetitle='$pagetitle'";

$obj=new DBController();

$result=$obj->runQuery($query);

if($result)
{

echo "record updated";
}
else
{
echo "not updated";
}
?>

========================================================================
DELETE  QUERY USING OBJECT ORIENTED
========================================================================

(1)Write code  for  delete.html file:

<form action="delete.php"  method="post">
Page title<input type=text name=pagetitle>
<input type=submit name=delete  value=delete>
</form>

(2)write code for delete.php file:

<?php

include('database.php');

$pagetitle=$_POST['pagetitle'];


$query="delete from about where pagetitle='$pagetitle'";

$obj=new DBController();

$result=$obj->runQuery($query);

if($result)
{

echo "record deleted";
}
else
{
echo "not deleted";
}
?>


========================================================================
DISPLAY ALL RECORD   QUERY USING OBJECT ORIENTED
========================================================================

<?php

include('database.php');

$query="select * from about";
$obj=new DBController();
$data=$obj->displayQuery($query);
  foreach($data as $v) 
  {
 echo $v['pagetitle'];
 echo $v['keyword'];
 echo $v['description'];
 echo $v['editor1'];
 echo '<br>';
  }

?>

========================================================================
SEARCH  RECORD   QUERY USING OBJECT ORIENTED
========================================================================
(1)Write code for search.html file:

<form action="search.php"  method="post">
Page title<input type=text name=pagetitle>
<input type=submit name=search  value=search>
</form>

(2)Write code for search.php file:

<?php
include('database.php');
$pagetitle=$_POST['pagetitle'];
$query="select * from about where pagetitle='$pagetitle'";
$obj=new DBController();
$data=$obj->displayQuery($query);
$num=$obj->numRows($query);
if($num>0)
{


  foreach($data as $v)
  {
 echo $v['pagetitle'];
 echo $v['keyword'];
 echo $v['description'];
 echo $v['editor1'];
 echo '<br>';
  }
}
else
{
echo "no record found";
}

?>


================================================================================================================================================

(1)write code  for    calculater_view.php :
<?php
require_once 'calculator.php';
$obj= new Calculator();
?>
<html>
    <head>
        <title>Loop Example</title>
    </head>
    <body>
        <form action="calculater_view.php" method="post">
            <table>
                <tr>
                    <td>First Number </td>
                    <td>
                        <input type="text" name="first_number" value="">
                    </td>
                </tr>
                <tr>
                    <td>Ending Number </td>
                    <td>
                        <input type="text" name="second_number" value="">
                    </td>
                </tr>
               
                <tr>
                    <td>&nbsp;</td>
                    <td>
                        <input type="submit" name="btn" value="+">
                        <input type="submit" name="btn" value="-">
                        <input type="submit" name="btn" value="*">
                        <input type="submit" name="btn" value="/">
                        <input type="submit" name="btn" value="%">
                       
                    </td>
                </tr>
                <?php
                        if(isset($_POST['btn']))
                        {
                            $first_number=$_POST['first_number'];
                            $second_number=$_POST['second_number'];
                           
                            if($_POST['btn']=='+')
                            {
                                $result= $obj->add($first_number,$second_number);
                            }
                            if($_POST['btn']=='-')
                            {
                                $result= $obj->sub($first_number,$second_number);
                            }
                            if($_POST['btn']=='*')
                            {
                                $result= $obj->mul($first_number,$second_number);
                            }
                            if($_POST['btn']=='/')
                            {
                                $result= $obj->div($first_number,$second_number);
                            }
                            if($_POST['btn']=='%')
                            {
                                $result= $obj->rim($first_number,$second_number);
                            }
                           
                        }
                       
                       
                       
                        ?>
                <tr>
                    <td><?php echo $result['lbl'];?></td>
                    <td>
                        <?php echo $result['value'];?>
                    </td>
                </tr>
            </table>
        </form>
    </body>
</html>
(2)write code for calculator.php file:
<?php
class Calculator{
   function  add($first_number,$second_number)
    {   $result=array();
        $result['value']=$first_number+$second_number;
        $result['lbl']='Addition';
        return $result;
    }
  function  sub($first_number,$second_number)
    {
        $result=array();
        $result['value']=$first_number-$second_number;
        $result['lbl']='Subtruction';
        return $result;
    }
    function  mul($first_number,$second_number)
    {
        $result=array();
        $result['value']=$first_number*$second_number;
        $result['lbl']='Multiplication';
        return $result;
    }
    function  div($first_number,$second_number)
    {
        $result=array();

        if($second_number==0)
        {
            $result='Undefine';
            $result['lbl']='Divition';
            return $result;
        }
        else{
        $result=array();
        $result['value']=$first_number/$second_number;
        $result['lbl']='Divition';
        return $result;
        }
    }
  function  rim($first_number,$second_number)
    {
        $result=array();
        if($second_number==0)
        {
            $result='Undefine';
            $result['lbl']='Reminder';
            return $result;
        }
        else{
        $result['value']=$first_number%$second_number;
        $result['lbl']='Reminder';
        return $result;
        }
    }
}


?>

output:

================================================================================================================================================
another example :
(1)first write code for calculator.php  file:
<?php


class calculator
{

function display()
{
                print("<HTML>\n");
                print("<HEAD>\n");
                print("<TITLE>JavaScript with PHP Calculator</TITLE>\n");
                print("<SCRIPT LANGUAGE='JavaScript'>\n");
                print("/**************************************\n");
                print(" *  www.phpdevelopmenttricks.blogspot.com *\n");
                print(" **************************************/\n");
                print("\n");
                print("// Declare global variables\n");
                print("var displayText = \"\"\n");
                print("var num1\n");
                print("var num2\n");
                print("var operatorType\n");
                print("\n");
                print("// Write to display\n");
                print("function addDisplay(n){\n");
                print("document.calc.display.value = \"\"\n");
                print("displayText += n\n");
                print("document.calc.display.value = displayText\n");
                print("}\n");
                print("\n");
                print("// Addition\n");
                print("function addNumbers() {\n");
                print("if (displayText == \"\") {\n");
                print(" displayText = result\n");
                print(" }\n");
                print("num1 = parseFloat(displayText)\n");
                print("operatorType = \"add\"\n");
                print("displayText = \"\"\n");
                print("}\n");
                print("\n");
                print("// Subtraction\n");
                print("function subtractNumbers() {\n");
                print("if (displayText == \"\") {\n");
                print(" displayText = result\n");
                print(" }\n");
                print("num1 = parseFloat(displayText)\n");
                print("operatorType = \"subtract\"\n");
                print("displayText = \"\"\n");
                print("}\n");
                print("\n");
                print("// Multiplication\n");
                print("function multiplyNumbers() {\n");
                print("if (displayText == \"\") {\n");
                print(" displayText = result\n");
                print(" }\n");
                print("num1 = parseFloat(displayText)\n");
                print("operatorType = \"multiply\"\n");
                print("displayText = \"\"\n");
                print("}\n");
                print("\n");
                print("// Division\n");
                print("function divideNumbers() {\n");
                print("if (displayText == \"\") {\n");
                print(" displayText = result\n");
                print(" }\n");
                print("num1 = parseFloat(displayText)\n");
                print("operatorType = \"divide\"\n");
                print("displayText = \"\"\n");
                print("}\n");
                print("\n");
                print("// Sine\n");
                print("function sin() {\n");
                print("if (displayText == \"\") {\n");
                print(" num1 = result\n");
                print(" }\n");
                print("else {\n");
                print(" num1 = parseFloat(displayText)\n");
                print(" }\n");
                print("if (num1 != \"\") {\n");
                print(" result = Math.sin(num1)\n");
                print(" document.calc.display.value = result\n");
                print(" displayText = \"\"\n");
                print(" }\n");
                print("else {\n");
                print(" alert(\"Please write the number first\")\n");
                print(" }\n");
                print("}\n");
                print("\n");
                print("// Cosine\n");
                print("function cos() {\n");
                print("if (displayText == \"\") {\n");
                print(" num1 = result\n");
                print(" }\n");
                print("else {\n");
                print(" num1 = parseFloat(displayText)\n");
                print(" }\n");
                print("if (num1 != \"\") {\n");
                print(" result = Math.cos(num1)\n");
                print(" document.calc.display.value = result\n");
                print(" displayText = \"\"\n");
                print(" }\n");
                print("else {\n");
                print(" alert(\"Please write the number first\")\n");
                print(" }\n");
                print("}\n");
                print("\n");
                print("// ArcSine\n");
                print("function arcSin() {\n");
                print("if (displayText == \"\") {\n");
                print(" num1 = result\n");
                print(" }\n");
                print("else {\n");
                print(" num1 = parseFloat(displayText)\n");
                print(" }\n");
                print("if (num1 != \"\") {\n");
                print(" result = Math.asin(num1)\n");
                print(" document.calc.display.value = result\n");
                print(" displayText = \"\"\n");
                print(" }\n");
                print("else {\n");
                print(" alert(\"Please write the number first\")\n");
                print(" }\n");
                print("}\n");
                print("\n");
                print("// ArcCosine\n");
                print("function arcCos() {\n");
                print("if (displayText == \"\") {\n");
                print(" num1 = result\n");
                print(" }\n");
                print("else {\n");
                print(" num1 = parseFloat(displayText)\n");
                print(" }\n");
                print("if (num1 != \"\") {\n");
                print(" result = Math.acos(num1)\n");
                print(" document.calc.display.value = result\n");
                print(" displayText = \"\"\n");
                print(" }\n");
                print("else {\n");
                print(" alert(\"Please write the number first\")\n");
                print(" }\n");
                print("}\n");
                print("\n");
                print("// Square root\n");
                print("function sqrt() {\n");
                print("if (displayText == \"\") {\n");
                print(" num1 = result\n");
                print(" }\n");
                print("else {\n");
                print(" num1 = parseFloat(displayText)\n");
                print(" }\n");
                print("if (num1 != \"\") {\n");
                print(" result = Math.sqrt(num1)\n");
                print(" document.calc.display.value = result\n");
                print(" displayText = \"\"\n");
                print(" }\n");
                print("else {\n");
                print(" alert(\"Please write the number first\")\n");
                print(" }\n");
                print("}\n");
                print("\n");
                print("// Square number (number to the power of two)\n");
                print("function square() {\n");
                print("if (displayText == \"\") {\n");
                print(" num1 = result\n");
                print(" }\n");
                print("else {\n");
                print(" num1 = parseFloat(displayText)\n");
                print(" }\n");
                print("if (num1 != \"\") {\n");
                print(" result = num1 * num1\n");
                print(" document.calc.display.value = result\n");
                print(" displayText = \"\"\n");
                print(" }\n");
                print("else {\n");
                print(" alert(\"Please write the number first\")\n");
                print(" }\n");
                print("}\n");
                print("\n");
                print("// Convert degrees to radians\n");
                print("function degToRad() {\n");
                print("if (displayText == \"\") {\n");
                print(" num1 = result\n");
                print(" }\n");
                print("else {\n");
                print(" num1 = parseFloat(displayText)\n");
                print(" }\n");
                print("if (num1 != \"\") {\n");
                print(" result = num1 * Math.PI / 180\n");
                print(" document.calc.display.value = result\n");
                print(" displayText = \"\"\n");
                print(" }\n");
                print("else {\n");
                print(" alert(\"Please write the number first\")\n");
                print(" }\n");
                print("}\n");
                print("\n");
                print("// Convert radians to degrees\n");
                print("function radToDeg() {\n");
                print("if (displayText == \"\") {\n");
                print(" num1 = result\n");
                print(" }\n");
                print("else {\n");
                print(" num1 = parseFloat(displayText)\n");
                print(" }\n");
                print("if (num1 != \"\") {\n");
                print(" result = num1 * 180 / Math.PI\n");
                print(" document.calc.display.value = result\n");
                print(" displayText = \"\"\n");
                print(" }\n");
                print("else {\n");
                print(" alert(\"Please write the number first\")\n");
                print(" }\n");
                print("}\n");
                print("\n");
                print("// Calculations\n");
                print("function calculate() {\n");
                print("if (displayText != \"\") {\n");
                print(" num2 = parseFloat(displayText)\n");
                print("// Calc: Addition\n");
                print(" if (operatorType == \"add\") {\n");
                print(" result = num1 + num2\n");
                print(" document.calc.display.value = result\n");
                print(" }\n");
                print("// Calc: Subtraction\n");
                print(" if (operatorType == \"subtract\") {\n");
                print(" result = num1 - num2\n");
                print(" document.calc.display.value = result\n");
                print(" }\n");
                print("// Calc: Multiplication\n");
                print(" if (operatorType == \"multiply\") {\n");
                print(" result = num1 * num2\n");
                print(" document.calc.display.value = result\n");
                print(" }\n");
                print("// Calc: Division\n");
                print(" if (operatorType == \"divide\") {\n");
                print(" result = num1 / num2\n");
                print(" document.calc.display.value = result\n");
                print(" }\n");
                print(" displayText = \"\"\n");
                print(" }\n");
                print(" else {\n");
                print(" document.calc.display.value = \"Oops! Error!\"\n");
                print(" }\n");
                print("}\n");
                print("\n");
                print("// Clear the display\n");
                print("function clearDisplay() {\n");
                print("displayText = \"\"\n");
                print("document.calc.display.value = \"\"\n");
                print("}\n");
                print("</SCRIPT>\n");
                print("</HEAD>\n");
                print("<BODY BGCOLOR=\"#FFFFFF\" LINK=\"#9C6060\">\n");
                print("\n");
                print("<TABLE>\n");
                print("<TD> \n");
                print("<TABLE BORDER=0 BGCOLOR=\"#AF9999\">\n");
                print("<TD>\n");
                print("<TABLE border=\"0\" cellpadding=\"2\" cellspacing=\"2\">\n");
                print("<FORM NAME=calc>\n");
                print("\n");
                print("<!--\n");
                print("<TR><TD VALIGN=top colspan=6 ALIGN=\"center\"> <H2>Calculator</H2>
                </TD>\n");
                print("-->\n");
                print("<TR>\n");
                print(" <TD COLSPAN=5><INPUT TYPE=text SIZE=22 NAME=display></TD>\n");
                print("<TR align=\"left\" valign=\"middle\">\n");
                print(" <TD><INPUT TYPE=button NAME=\"one\" VALUE=\"  1   \"
                onClick=addDisplay(1)></TD>\n");
                print(" <TD><INPUT TYPE=button NAME=\"two\" VALUE=\"  2   \"
                onClick=addDisplay(2)></TD>\n");
                print(" <TD><INPUT TYPE=button NAME=\"three\" VALUE=\"  3   \"
                onClick=addDisplay(3)></TD>\n");
                print(" <TD><INPUT TYPE=button NAME=\"plus\" VALUE=\"  +   \"
                onClick=addNumbers()></TD>\n");
                print("<TR align=\"left\" valign=\"middle\">\n");
                print(" <TD><INPUT TYPE=button NAME=\"four\" VALUE=\"  4   \"
                onClick=addDisplay(4)></TD>\n");
                print(" <TD><INPUT TYPE=button NAME=\"five\" VALUE=\"  5   \"
                onClick=addDisplay(5)></TD>\n");
                print(" <TD><INPUT TYPE=button NAME=\"six\" VALUE=\"  6   \"
                onClick=addDisplay(6)></TD>\n");
                print(" <TD><INPUT TYPE=button NAME=\"minus\" VALUE=\"   -   \"
                onClick=subtractNumbers()></TD>\n");
                print("<TR align=\"left\" valign=\"middle\">\n");
                print(" <TD><INPUT TYPE=button NAME=\"seven\" VALUE=\"  7   \"
                onClick=addDisplay(7)></TD>\n");
                print(" <TD><INPUT TYPE=button NAME=\"eight\" VALUE=\"  8   \"
                onClick=addDisplay(8)></TD>\n");
                print(" <TD><INPUT TYPE=button NAME=\"nine\" VALUE=\"  9   \"
                onClick=addDisplay(9)></TD>\n");
                print(" <TD><INPUT TYPE=button NAME=\"multiplication\" VALUE=\"  *    \"
                onClick=multiplyNumbers()></TD>\n");
                print("<TR align=\"left\" valign=\"middle\">\n");
                print(" <TD><INPUT TYPE=button NAME=\"zero\" VALUE=\"  0   \"
                onClick=addDisplay(0)></TD>\n");
                print(" <TD><INPUT TYPE=button NAME=\"pi\" VALUE = \" Pi  \"
                onClick=addDisplay(Math.PI)> </TD> \n");
                print(" <TD><INPUT TYPE=button NAME=\"dot\" VALUE=\"   .   \"
                onClick=addDisplay(\".\")></TD>\n");
                print(" <TD><INPUT TYPE=button NAME=\"division\" VALUE=\"   /   \"
                onClick=divideNumbers()></TD>\n");
                print("<TR align=\"left\" valign=\"middle\">\n");
                print(" <TD><INPUT TYPE=button NAME=\"sqareroot\" VALUE=\"sqrt\"
                onClick=sqrt()></TD>\n");
                print(" <TD><INPUT TYPE=button NAME=\"squarex\" VALUE=\" x^2\"
                onClick=square()></TD>\n");
                print(" <TD><INPUT TYPE=button NAME=\"deg-rad\" VALUE=\"d2r \"
                onClick=degToRad()></TD>\n");
                print(" <TD><INPUT TYPE=button NAME=\"rad-deg\" VALUE=\"r2d \"
                onClick=radToDeg()></TD>\n");
                print("<TR align=\"left\" valign=\"middle\">\n");
                print(" <TD><INPUT TYPE=button NAME=\"sine\" VALUE=\" sin \"
                onClick=sin()></TD>\n");
                print(" <TD><INPUT TYPE=button NAME=\"arcsine\" VALUE=\"asin\"
                onClick=arcSin()></TD>\n");
                print(" <TD><INPUT TYPE=button NAME=\"cosine\" VALUE=\"cos\"
                onClick=cos()></TD>\n");
                print(" <TD><INPUT TYPE=button NAME=\"arccosine\" VALUE=\"acs\"
                onClick=arcCos()></TD>\n");
                print("\n");
                print("<TR align=\"left\" valign=\"middle\">\n");
                print(" <TD COLSPAN=2><INPUT TYPE=button NAME=clear VALUE=\"  Clear  \"
                onClick=clearDisplay()></TD>\n");
                print(" <TD COLSPAN=3><INPUT TYPE=button NAME=enter VALUE=\"     =      \"
                onClick=calculate()></TD>\n");
                print("\n");
                print("</TABLE>\n");
                print(" <!--\n");
                print(" <TD VALIGN=top> \n");
                print(" <B>NOTE:</B> All sine and cosine calculations are\n");
                print(" <br>done in radians. Remember to convert first\n");
                print(" <br>if using degrees.\n");
                print(" </TD>\n");
                print(" -->\n");
                print(" \n");
                print("</TABLE>\n");
                print("\n");
                print("\n");
                print("</TABLE>\n");
                print("</BODY>\n");
                print("</HTML>\n");
}

}

?>
(2)write code for  sample.php   file:
<?php
                // Sample calculator program - demos usage

                //include_once("calculator.php");
                require_once("calculator.php");
                $calc = new calculator();
                $calc->display();
?>
Note: now  run  “Localhost/sample.php file “

Then you will get following output:





Demikianlah Artikel Object oriented Programming Practice for including all database connectivity insert,update ,delete ,display code all in one in a single page :

Sekianlah artikel Object oriented Programming Practice for including all database connectivity insert,update ,delete ,display code all in one in a single page : kali ini, mudah-mudahan bisa memberi manfaat untuk anda semua. baiklah, sampai jumpa di postingan artikel lainnya.

Anda sekarang membaca artikel Object oriented Programming Practice for including all database connectivity insert,update ,delete ,display code all in one in a single page : dengan alamat link https://othereffect.blogspot.com/2016/02/object-oriented-programming-practice.html

0 Response to "Object oriented Programming Practice for including all database connectivity insert,update ,delete ,display code all in one in a single page :"

Post a Comment