Q:

I am using two IN and OUT param in store procedure where I am getting two result, I want the two result in PHP

    CREATE PROCEDURE `prev1`(IN `page` INT(50), OUT `foundrows` INT(255))
BEGIN DECLARE foundrows varchar(255);
SELECT SQL_CALC_FOUND_ROWS  * FROM studentmarks limit page ,6;
SELECT FOUND_ROWS()as foundrows;
END

this is my php code
$pag=$_GET["offset"];
$sql="call prev1($pag,@foundrows)";
$result = mysqli_query($conn,$sql);

and my response is
mysqli_result Object
(    [current_field] => 0  
  [field_count] => 13   
 [lengths] =>   
  [num_rows] => 6   
 [type] => 0
)

but my found_rows is not  getting in php.  but my total found_rows is 19 but is showing only  [num_rows] => 6   

A:

To return a value with a stored procedure:

SQL :
 DELIMITER //
 CREATE PROCEDURE prev1(IN `page` INT, OUT `Out_val` INT)
 BEGIN
    SELECT SQL_CALC_FOUND_ROWS  * FROM studentmarks limit page ,6;
    SELECT FOUND_ROWS() INTO Out_val;
 END //
 DELIMITER ;

PHP Code:
<? php
error_reporting(-1);
ini_set('display_errors', 'On');

? >
<! DOCTYPE html>
<html>
<body>

<? php
$servername = "localhost";
$username = "root";
$password = "password";
$dbname = "dbname";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " .  $conn->connect_error);
} 

 $pag = 1;
 $conn->multi_query("CALL prev1($pag,@Out_val);SELECT @Out_val as count");
do {
    /* store first result set */
    if ($result = $conn->store_result()) {
        while ($row = $result->fetch_row()) {
            print_r($row);
        }
        $result->free();
    }
    /* print divider */
    if ($conn->more_results()) {
        printf("-----------------\n");
    }
} while ($conn->next_result());

? > 

</body>
</html>

I hope this will help.