how can I do a SELECT * FROM WHILE with a PHP Array?

0

I have a query ... I have in a table called coins a field called Prefix and in another table called directories I have a field where I keep the word DEL ie

What I want is to show in a select-box is, first to unfold country and city, and in another select box to display the available currencies, of course this is an example since in reality I have a directory of more than 3 thousand records where each country is divided by city and each city is divided by districts and each district has certain agendas, then the solution to tie the tables was to put only one field where those prefixes are since this will then be used in another rate table and has fields as the initial range and final rank and each country, city, etc ... has different rates ... to avoid creating another table where each agency has different rates would give me a huge result and it would be impractical to apply this since it would be prone to changes and maintaining this table would be impossible because of the colossal number of records that is why I try to do in a selec * from an asosiative array in PHP

this is the code:

<?php 
    $vMonedas_Habilitadas=$_POST['Prefijo'];

    //--->Prefijo es de la tabla directorio = DEL

	$Arreglo = str_split($vMonedas_Habilitadas);

    //segun lo que lei en el manual de php la funcion str_split me devuelve una cadena en arreglo entonces aqui convierto el string DEL en array [D,E,L]

    //ya teniendo el array [D,E,L] ahora quiero filtrar que monedas estan disponibles al seleccionar un registro
    $result = "SELECT * FROM tabla_moneda WHERE Prefijo IN (".implode(",",$Arreglo).")";


$resultadoMD = $mysqli->query($result);

$html= "<option value='0' selected >Moneda no seleccionada</option>";

while($row = $resultadoMD->fetch_assoc())
	{
		$html.= "<option value='".$row['vIndicador']."'>".$row['vNombre_Moneda']."</option>";
	}

	echo $html;

 ?>

I tried to filter but I still do not succeed in the execution of the code the error could be in the SQL query I used the implode command but my code does not execute

Any way to do a SELECT * FROM with an asosiative array?

I was looking for related topics but not specifically to what I try to do, in advance I give thanks to the recommendations or solutions.

    
asked by 22.09.2018 в 22:15
source

1 answer

0

I think you are not printing the fields in your database correctly. You try to print the vIndicator and vCamerName fields when they are n and CurrencyName .

Try changing:

$html.= "<option value='".$row['vIndicador']."'>".$row['vNombre_Moneda']."</option>";

By:

$html.= "<option value='".$row['n']."'>".$row['NombreMoneda']."</option>";
    
answered by 22.09.2018 в 22:22