How to loop within a query?

1

I have a list of phone numbers and their carriers. This list is in the form of icons and when you mouse over the operator-related number in tooltip format. However, the same number is appearing for all carriers as can be seen here , just move your mouse over the phone icon in the lower right corner.

My query looks like this:

$tel_query = "SELECT * FROM tels";
$variavel_exe = mysql_query($tel_query) or die(mysql_error());
while($variavel = mysql_fetch_array($variavel_exe)){
    $indTelefone=0;
    $indCelular=0;
    while($tipo = mysql_fetch_array($variavel_exe)){
        if($tipo['tipo']=='fixo'){
            $arrayTelefone[$indTelefone]['numero'] = $tipo['numero'];
            $indTelefone++;
        }else{
            $arrayCelular[$indCelular]['numero'] = $tipo['numero'];
            $indCelular++;
        }
    }
}

Can a colleague please help me resolve this issue? Thanks!

  

In time, I'm using Google Material Design for the interface (the framework is fantastic) and of course, PHP with MySQL.

    
asked by anonymous 14.11.2015 / 13:53

1 answer

2

Removing one of the links will get the expected result:

$tel_query = "SELECT * FROM tels";
$variavel_exe = mysql_query($tel_query) or die(mysql_error());

$indTelefone=0;
$indCelular=0;
    while($tipo = mysql_fetch_array($variavel_exe)){
        if($tipo['tipo']=='fixo'){
            $arrayTelefone[$indTelefone]['numero'] = $tipo['numero'];
            $indTelefone++;
        }else{
            $arrayCelular[$indCelular]['numero'] = $tipo['numero'];
            $indCelular++;
        }
    }
}
    
14.11.2015 / 14:51