delimiter //
create procedure sp_AttendReportCountWorkouts(OUT cnt INT)
begin select count(*) into cnt from workout_details;
end;
I have created the above stored procedure in MySQL and I’m trying to take count of records but I am not able to get the desired result. The following is actual code on my PHP page.
$link = mysqli_connect('localhost', 'root', '', 'icoachswim_sp');
if (!$link)
{
printf("Can't connect to MySQL Server. Errorcode: %s\n", mysqli_connect_error());
exit;
}
if ($count = mysqli_query($link,"call sp_AttendReportCountWorkouts()"))
{
}
In your example $count is just a reference to MySQL result.
Here is an idea how to process that reference and get the actual result.
Update: this is just an example assuming the stored procedure is not using out parameter:
With an out paramter is has to be either multi_query like other answer shows or two sequential calls: