so I'm trying to take all the ofice_id and 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
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);
while($row = mysqli_fetch_assoc($s) ) {
$result_arry[] = $row;
}
}