0

I took all the ofice_id and I'm trying to pass them to this function to handle all the office but I need to store the result in $result_arry[] and that what I have

mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, bool given in

I'm sure the query is working and everything is good but couldn't fix this the output

Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, bool given in C:\xampp\htdocs\test\root\inc\char_data.php on line 24

Array ( [0] => Array ( [COUNT(office_id)] => 1 ) [1] => 1 [2] => [3] => 3 )

DELIMITER //
CREATE PROCEDURE AN_M(IN id VARCHAR(255))
BEGIN

DECLARE start_date date;
DECLARE price_m DOUBLE;
DECLARE months int;

SELECT contract_start , price_month  INTO start_date  , price_m
FROM rent

/* here we take the diff betwen months*/ 
set months =TIMESTAMPDIFF(month, start_date, GetDate());

set @to_pay = months * price_m ;

SELECT COUNT(office_id) 
FROM rent
where price_pid > @to_pay;

END //
DELIMITER ;

PHP script:

<?php

require('DB.php');

$sql_rented = "SELECT office_id as id from rent ;";
$rented = mysqli_query($conn, $sql_rented);

$id = array();
$result_arry =array();

while($row = mysqli_fetch_assoc($rented) ) {
 
  $id[] = $row;
}



foreach ( $id as $value )
{
  $value = implode($value);
  
  $sql = "CALL AN_M('$value');";
  $s = mysqli_query($conn, $sql); 
  $row = mysqli_fetch_assoc($s);
  $result_arry[] = array_push($result_arry ,$row);
  
}

print_r($result_arry);
Dharman
  • 30,962
  • 25
  • 85
  • 135

0 Answers0