i have the two table once main table another once audit table for back up process if delete the record only on audit... if the record was deleted from audit means then update status on main table..... for example table structure of main table
id name status
==============
1 raj 1
2 arivu 0
for example table structure of audit table
id name status
==============
1 raj 1
2 arivu 0
here the status 1 is active and 0 is inactive
if i delete the record from the audit table then output like for example table structure of audit table
id name status
==============
1 raj 1
and main table for example table structure of audit table
id name status
==============
1 raj 1
2 arivu 2
if delete any record from audit table the record status is 0 or 1 just update it to 2
now i write procedure for solve the problem but i dont know how to call the procedure on php page My Procedure is like
DELIMITER $$
DROP PROCEDURE IF EXISTS `users` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `users`(in id int(25))
BEGIN
delete from person_history where id=id ;
update person set active='2' where id=id ;
END $$
DELIMITER ;
just like you would call a normal query
call Procedurename('parameter')
should work
I assume that you are using mysqli_*
$result = mysqli_query($connection, "CALL users('$parameter')") or die("Query fail: " . mysqli_error());
This should works:
$id = 35; //hard coded, but you can replace this with a post or get var
$qry = "call users({$id});";
mysqli_query($conn,$qry);
<?php
//connect to database
$connection = mysqli_connect("hostname", "user", "password", "db", "port");
//run the store proc
$result = mysqli_query($connection,
"CALL StoreProcName") or die("Query fail: " . mysqli_error());
//loop the result set
while ($row = mysqli_fetch_array($result)){
echo $row[0] . " - " . + $row[1];
}
?>
Note : Above code has been taken from How to call a MySQL stored procedure from within PHP code