Call count result from stored procedure MySQL in PHP

I'm trying to get a value from a stored procedure in php but I can't do it.

My stored procedure:

DROP PROCEDURE IF EXISTS sp_table;
DELIMITER $$
CREATE PROCEDURE sp_table()
BEGIN
SELECT COUNT(*) FROM table;
END$$
DELIMITER ;

My PHP code:

$recordSet_table = $conn->query("CALL sp_table()");

print_r($recordSet_table)."<br><br>";

Upvotes: 1

Views: 356

Answers (1)

user2181132
user2181132

Reputation: 19

Please try following code.

$sql = mysqli_query($connectionVariable,"CALL sp_table(@count)");

$result = mysqli_fetch_array($sql);

Upvotes: 1

Related Questions