Skip to main content

Connection

<?php
class Demo
{
var $con;

function __construct()  //contructor
{
$this->con=new mysqli('localhost','root','','php');
if(!$this->con)
echo "Connection Failed";
}

function setData($sql)
{
if($this->con->query($sql))
{
echo "Data inserted";
}
}

function getData()
{
$result=$this->con->query("select * from tbl_demo");
while($row=$result->fetch_assoc())
{
echo $row['fname']." ".$row['lname']."<br>";
}
}

}
class Demo2 extends Demo
{

}
$a=new Demo();
$b=new Demo2();
$sql="insert into tbl_demo (fname,lname) values ('ramesh','suresh')";
//$a->setData($sql);  //Insert Data
//$a->getData(); //get data using parent class
$b->getData(); //get data using child class

?>

Comments

Popular posts from this blog

DELL ES

<!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html>     <head>         <meta charset="UTF-8">         <title></title>     </head>     <body>         <?php                     include './Conn.php';                     $sv="select * from demo";                     $qsv= mysqli_query($conn, $sv);                                 ?>     <center>         <table border="1">           ...

SRCH OP

<!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <?php ob_start(); ?> <html>     <head>         <meta charset="UTF-8">         <title></title>         <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>   <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>     </head>     <style>       body{           background-color: aliceblue;       }   </style>     <body>     ...

IMAGE UP BACK

<!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html>     <head>         <meta charset="UTF-8">         <title></title>         <style>             h1{                 font-family: monospace;                 color: black;                 text-align: center;             }             h3{                 text-align: left;             }         </style>     </head>     <body> ...