<?php
try{
$con = new PDO("mysql:host=localhost;dbname=systemwebtechonline", 'root','');
echo "Connection Created Successfully";
}
catch(PDOException $e){
echo "Error" . $e->getMessage();
}
?>
PHP PDO Tutorials in Urdu/Hindi 2 of 5 PDO Select Query
<?php
try{
$con = new PDO("mysql:host=localhost;dbname=systemwebtechonline", 'root','');
$sth = $con->prepare("SELECT * FROM admin");
$sth->setFetchMode(PDO::FETCH_OBJ);
$sth->execute();
while($row = $sth->fetch()){
echo $row->email."<br>";
echo $row->pass."<br>";
}
}
catch(PDOException $e){
echo "Error" . $e->getMessage();
}
?>
PHP PDO Tutorials in Urdu/Hindi 3 of 5 Insert Query
<?php
try{
$con = new PDO("mysql:host=localhost;dbname=systemwebtechonline", 'root','');
//$sth = $con->prepare("SELECT * FROM admin");
$email = "agdevika@gmail.com";
$pass = "devika";
$sth = $con->prepare("INSERT INTO admin (email,pass) VALUES (:email,:pass)");
$sth->bindParam(':email',$email);
$sth->bindParam(':pass',$pass);
$sth->setFetchMode(PDO::FETCH_OBJ);
$sth->execute();
echo "Data Inserted";
while($row = $sth->fetch()){
echo $row->email."<br>";
echo $row->pass."<br>";
}
}
catch(PDOException $e){
echo "Error" . $e->getMessage();
}
?>
PHP PDO Tutorials in Urdu/Hindi 4 of 5 Update Query
<?php
try{
$con = new PDO("mysql:host=localhost;dbname=systemwebtechonline", 'root','');
$sth = $con->prepare("UPDATE admin SET email='k@yahoo.com' where id='1'");
$sth->execute();
echo $sth->rowCount()."Recored Updated";
/*$sth = $con->prepare("SELECT * FROM admin");
//$email = "agdevika@gmail.com";
$pass = "devika";
$sth = $con->prepare("INSERT INTO admin (email,pass) VALUES (:email,:pass)");
$sth->bindParam(':email',$email);
$sth->bindParam(':pass',$pass);
$sth->setFetchMode(PDO::FETCH_OBJ);
$sth->execute();
echo "Data Inserted";
*/
while($row = $sth->fetch()){
echo $row->email."<br>";
echo $row->pass."<br>";
}
}
catch(PDOException $e){
echo "Error" . $e->getMessage();
}
?>
PHP PDO Tutorials in Urdu/Hindi 5 of 5 Delete Query
<?php
try{
$con = new PDO("mysql:host=localhost;dbname=systemwebtechonline", 'root','');
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$query = ("DELETE FROM admin WHERE id='12'");
$con->exec($query);
echo "Record Deleted";
/* This Update Query Code
$sth = $con->prepare("UPDATE admin SET email='k@yahoo.com' where id='1'");
$sth->execute();
echo $sth->rowCount()."Recored Updated"; */
/*This is Insert Query Code
/*$sth = $con->prepare("SELECT * FROM admin");
//This Insert Query Code
//$email = "agdevika@gmail.com";
$pass = "devika";
$sth = $con->prepare("INSERT INTO admin (email,pass) VALUES (:email,:pass)");
$sth->bindParam(':email',$email);
$sth->bindParam(':pass',$pass);
$sth->setFetchMode(PDO::FETCH_OBJ);
$sth->execute();
echo "Data Inserted";
*/
while($row = $sth->fetch()){
echo $row->email."<br>";
echo $row->pass."<br>";
}
}
catch(PDOException $e){
echo "Error" . $e->getMessage();
}
?>
try{
$con = new PDO("mysql:host=localhost;dbname=systemwebtechonline", 'root','');
echo "Connection Created Successfully";
}
catch(PDOException $e){
echo "Error" . $e->getMessage();
}
?>
PHP PDO Tutorials in Urdu/Hindi 2 of 5 PDO Select Query
<?php
try{
$con = new PDO("mysql:host=localhost;dbname=systemwebtechonline", 'root','');
$sth = $con->prepare("SELECT * FROM admin");
$sth->setFetchMode(PDO::FETCH_OBJ);
$sth->execute();
while($row = $sth->fetch()){
echo $row->email."<br>";
echo $row->pass."<br>";
}
}
catch(PDOException $e){
echo "Error" . $e->getMessage();
}
?>
PHP PDO Tutorials in Urdu/Hindi 3 of 5 Insert Query
<?php
try{
$con = new PDO("mysql:host=localhost;dbname=systemwebtechonline", 'root','');
//$sth = $con->prepare("SELECT * FROM admin");
$email = "agdevika@gmail.com";
$pass = "devika";
$sth = $con->prepare("INSERT INTO admin (email,pass) VALUES (:email,:pass)");
$sth->bindParam(':email',$email);
$sth->bindParam(':pass',$pass);
$sth->setFetchMode(PDO::FETCH_OBJ);
$sth->execute();
echo "Data Inserted";
while($row = $sth->fetch()){
echo $row->email."<br>";
echo $row->pass."<br>";
}
}
catch(PDOException $e){
echo "Error" . $e->getMessage();
}
?>
PHP PDO Tutorials in Urdu/Hindi 4 of 5 Update Query
<?php
try{
$con = new PDO("mysql:host=localhost;dbname=systemwebtechonline", 'root','');
$sth = $con->prepare("UPDATE admin SET email='k@yahoo.com' where id='1'");
$sth->execute();
echo $sth->rowCount()."Recored Updated";
/*$sth = $con->prepare("SELECT * FROM admin");
//$email = "agdevika@gmail.com";
$pass = "devika";
$sth = $con->prepare("INSERT INTO admin (email,pass) VALUES (:email,:pass)");
$sth->bindParam(':email',$email);
$sth->bindParam(':pass',$pass);
$sth->setFetchMode(PDO::FETCH_OBJ);
$sth->execute();
echo "Data Inserted";
*/
while($row = $sth->fetch()){
echo $row->email."<br>";
echo $row->pass."<br>";
}
}
catch(PDOException $e){
echo "Error" . $e->getMessage();
}
?>
PHP PDO Tutorials in Urdu/Hindi 5 of 5 Delete Query
<?php
try{
$con = new PDO("mysql:host=localhost;dbname=systemwebtechonline", 'root','');
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$query = ("DELETE FROM admin WHERE id='12'");
$con->exec($query);
echo "Record Deleted";
/* This Update Query Code
$sth = $con->prepare("UPDATE admin SET email='k@yahoo.com' where id='1'");
$sth->execute();
echo $sth->rowCount()."Recored Updated"; */
/*This is Insert Query Code
/*$sth = $con->prepare("SELECT * FROM admin");
//This Insert Query Code
//$email = "agdevika@gmail.com";
$pass = "devika";
$sth = $con->prepare("INSERT INTO admin (email,pass) VALUES (:email,:pass)");
$sth->bindParam(':email',$email);
$sth->bindParam(':pass',$pass);
$sth->setFetchMode(PDO::FETCH_OBJ);
$sth->execute();
echo "Data Inserted";
*/
while($row = $sth->fetch()){
echo $row->email."<br>";
echo $row->pass."<br>";
}
}
catch(PDOException $e){
echo "Error" . $e->getMessage();
}
?>