how to create procedure in XAMPP-MYSQL and how to insert form data to database using Procedure

how to create procedure in XAMPP-MYSQL and how to insert form data to database using Procedure - Hallo sahabat Tutorials, Pada Artikel yang anda baca kali ini dengan judul how to create procedure in XAMPP-MYSQL and how to insert form data to database using Procedure, 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 : how to create procedure in XAMPP-MYSQL and how to insert form data to database using Procedure
link : how to create procedure in XAMPP-MYSQL and how to insert form data to database using Procedure

Baca juga


how to create procedure in XAMPP-MYSQL and how to insert form data to database using Procedure

(1)FIRST CREATE TABLE   tbl_ext:

SQL>
create table tbl_ext
(id  int primary key auto_increment,
name  varchar(200),
address  varchar(200)
);

======================================================================
INSERT   RECORD INTO DATABASE USING MYSQL PROCEDURE IN PHP:
======================================================================

(2)CREATE PROCEDURE  myinsert():

SQL>

CREATE PROCEDURE  myinsert(IN name varchar(20),IN adds varchar(200))

BEGIN INSERT INTO tbl_ext(name ,address)VALUES(name,adds);

End



(3)CALL PROCEDURE:

SQL>call  myinsert('OMji','VIRAR');

(4)WRITE  CODE  FOR   "insert.html"  file:

<form  action="insert.php"  method="post">
name<input type=text     name=name>
address<input type=text  name=address>
<input type=submit name=submit value="submit">
</form>


(5)WRITE CODE FOR  "insert.php"  file:

<?php
$con=mysql_connect("Localhost","root","");
mysql_select_db('abhi',$con);
$name=$_POST['name'];
$city=$_POST['address'];
$sql="call  myinsert('$name','$city')";
$result=mysql_query($sql);
if($result)
{
echo "record inserted";

}
else

{

echo "record not inserted";

}

?>



======================================================================
DISPLAY  DATABASE RECORD USING MYSQL PROCEDURE IN PHP:
======================================================================
(1)FIRST CREATE  PROCEDURE mydisplay():

SQL>CREATE PROCEDURE mydisplay()

BEGIN

select * from tbl_ext;

End

(2)WRITE CODE FOR  display.php file:

<?php
$con=mysql_connect("Localhost","root","");
mysql_select_db('abhi',$con);
$sql="call mydisplay()";
$result=mysql_query($sql);
while($row=mysql_fetch_array($result))
{

echo $row['id'];
echo $row['name'];
echo $row['address'];
}
?>


======================================================================
UPDATE  DATABASE RECORD USING MYSQL PROCEDURE IN PHP:
======================================================================

(1)CREATE PROCEDURE  myupdate():

SQL>CREATE PROCEDURE myupdate(IN myid varchar(20),IN myname varchar(20),IN myaddress varchar(20))
BEGIN
update tbl_ext  set name=myname,address=myaddress where id=myid;
End

(2)NOW WRITE CODE FOR  update.html :

<form  action="update.php"  method="post">
id<input type=text name=id>
name<input type=text     name=name>
address<input type=text  name=address>
<input type=submit name=submit value="submit">
</form>

(3)NOW WRITE CODE FOR update.php  file:

<?php
$con=mysql_connect("Localhost","root","");
mysql_select_db('abhi',$con);
$id=$_POST['id'];
$name=$_POST['name'];
$city=$_POST['address'];
$sql="call myupdate('$id','$name','$city')";
$result=mysql_query($sql);
if($result)
{
echo "record updated";
}
else
{
echo "record not updated";
}
?>

======================================================================
DELETE   DATABASE RECORD USING MYSQL PROCEDURE IN PHP:
======================================================================
(1)FIRST CREATE PROCEDURE   mydelete():

CREATE PROCEDURE mydelete(IN myid varchar(20))
BEGIN
delete from tbl_ext  where id=myid;
End

(2)WRITE CODE FOR  delete.html  file:

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

(3)NOW WRITE CODE FOR delete.php file:

<?php
$con=mysql_connect("Localhost","root","");
mysql_select_db('abhi',$con);
$id=$_POST['id'];

$sql="call mydelete('$id')";
$result=mysql_query($sql);
if($result)
{
echo "record deleted";
}
else
{
echo "record not deleted";
}
?>









Demikianlah Artikel how to create procedure in XAMPP-MYSQL and how to insert form data to database using Procedure

Sekianlah artikel how to create procedure in XAMPP-MYSQL and how to insert form data to database using Procedure kali ini, mudah-mudahan bisa memberi manfaat untuk anda semua. baiklah, sampai jumpa di postingan artikel lainnya.

Anda sekarang membaca artikel how to create procedure in XAMPP-MYSQL and how to insert form data to database using Procedure dengan alamat link https://othereffect.blogspot.com/2016/11/how-to-create-procedure-in-xampp-mysql.html

0 Response to "how to create procedure in XAMPP-MYSQL and how to insert form data to database using Procedure"

Post a Comment