hlo, i have a code... plz tell through this how to show table data from mysql?
tell me the sql query or code and the location where i will insert that
customers.php
<?php
class Customers
{
private $name;
private $id;
private $desc;
private $con;
public function __construct($name,$desc)
{
$this -> name = $name;
$this-> desc = $desc;
$this -> con = mysql_connect("localhost", "root", "");
$this -> db = mysql_select_db('cust');
}
public function insertData($desc_tbl)
{
$sql = " insert into $desc_tbl values (NULL,'".$this->name."','".$this->desc."');";
$res = mysql_query($sql);
mysql_query($res);
echo "<center>Record Inserted</center><br>";
$res = mysql_query("SELECT name,desc FROM desc_tbl");
}
public function deleteData($id)
{
$sql = " delete from desc_tbl";
$res = mysql_query($sql);
mysql_query($res);
echo "<center>Record Deleted</center><br>";
}
public function fetchData($id,$name,$desc)
{
$sql = " select * from desc_tbl";
$res = mysql_query($sql);
mysql_query($res[$id]);
echo "<center>Data is</center><br>";
}
public function updateData($desc_tbl,$name,$desc,$id)
{
$sql = " update desc_tbl set name='$name' , desc='$desc'";
$res = mysql_query($sql);
mysql_query($res);
echo "<center>Record Updated</center><br>";
}
}
?>
test.php
--------
<?php
require_once("customers.php");
$name = "John";
$desc ="Test Desc";
$id = "6";
$c = new Customers($name,$desc);
echo $c->insertData("desc_tbl");
//$c =new Customers($name,$desc,$id);
//echo $c->deleteData("desc_tbl");
?>
Thanks