hi, i need to put the result of my query into an array, then return it. here it is my code:
function getData($country) {
include("vars.php");
$conn=mysqli_connect($host, $user, $password) or die("No se pudo establecer comunicacion");
$db=mysqli_select_db($conn, $basedatos) or die("Error en la base de datos");
$xcountry=$country;
switch ($country) {
case "01":
$sql1="SELECT nommun from $tabla9 where coddep='$xcountry'";
$rs2=mysqli_query($conn, $sql1) or die(mysqli_error($conn));
$filas2=mysqli_num_rows($rs2);
$campos=mysqli_num_fields($rs2);
$nomcampos=mysql_field_name($rs2);
settype($retval,"array");
for($i=0;$i<$filas2;$i++){
for($j=0;$j<$campos;$j++){
$retval[$i]$nomcampos[$j] = mysqli_result($result,$i,$nomcampos,$j);
}//end inner loop
}//end outer loop
//return $retval;
so, in the first approach of this code, was working using this simple line:
return array('','AH01','AH02','AH03','AH04','AH05','AH06','AH07');
the result was send it ok, obvioulsy the goal is to get the data from a table, put it in the array and then send this array, i think this line in particular is the problem:
$retval[$i]$nomcampos[$j] = mysqli_result($result,$i,$nomcampos,$j);
but at this time, I don't get more ideas, so if you have suggestions will be welcome
regards