Instead of writing sql queries in the PHP code,
a Stored Procedure is a procedure written in SQL in your case MySQL and is stored in a database which can be called by the database engine and connected programming languages like PHP.
Refer:
stored-procedures-mysql-php[
^]