Dear in advance I appreciate your contributions, I am stuck in a logic that probably for many of you is quite simple and is the following: I have a table in MySQL and from it I get a number of records associated with the identification of the user like this:
Now, what I want to do is get the results of the column "credit_scale" to save them in PHP variables since I have to perform some operations on them, however, when making a query prepared using FetchAll I get the whole array but not I have the logic to interact with the array in such a way that I can obtain these results in the form of independent variables, as an example what I would like to obtain is the following:
$var1=saldo_credito[0];
$var2=saldo_credito[1];
$var3=saldo_credito[2];
Once again all your contributions are welcome and grateful of me. Greetings
Annex the portion of code that I am using to get to obtain the required result:
<?php
$ob1="";$ob2="";$ob3="";$ob4="";
$id=1111111;
$busqueda=$id;
try{ include("conexion2.php");
$base->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$base->exec("SET CHARACTER SET utf8");
$sql="SELECT identificacion, saldo_credito, id_reg FROM 't_nextracto' WHERE identificacion=? ORDER BY id_reg ASC";
//variable $resultado que almacena PDO statement
$stmt=$base->prepare($sql);
//ejecutar la funcion
$result=$stmt->execute(array($busqueda));
$rows=$stmt->fetchAll();
//Acá no se como generar la rutina de codigo para tomar los datos como variables.
print_r($rows);
$stmt->closecursor();
}catch(exception $e)
{
die('Error: ' . $e->GetMessage());
}finally{
$base=null;
}
?>