I have the following query
$resp = $conexionAd->query("select negocio.codigo from negocio where plantilla = 'plantilla1'")or die($conexionAd -> error);
while($fila = mysqli_fetch_array($resp)){
$re7 = $conexionCa->query("select count(id) from productos where codigo = '".$fila[0]."' group by codigo")or die($conexionCa -> error);
while($fila7 = mysqli_fetch_row($re7)){
print_r($fila7);
}
}
print_r($fila7);
Array ( [0] => 4 )
Array ( [0] => 23 )
$value7 = 23
I need to add values of key[0] to get $value7 = 27
You can create an initialized variable a
0
and then add values to it, for example:However, you should seriously think about optimizing and, if possible, having everything in the same database.
On the other hand, avoid mixing styles. I've changed the code to object-oriented style, which you were already using when calling
query()
.