Hello
From a csv file, because after doing submit
on the form I do not have the return with the correct values?
If%% of countries is equal $_POST
, I wanted you to return the $ registry [0] and $registo[1]
corresponding to that $registo[2]
<?php
$br = "</br>";
$file = fopen("paises.txt", "r");
$codigo = (isset($_POST['codigo']) ? $_POST['codigo'] : null);
$pais = (isset($_POST['pais']) ? $_POST['pais'] : null);
$capital = (isset($_POST['capital']) ? $_POST['capital'] : null);
$cod = "";
$cap = "";
if (array_key_exists("pais", $_POST)) {
echo "<table border='1'><th>Pais</th>";
while (!feof($file)) {
$registo = fgetcsv($file);
if ($pais = $registo[1]) {
$cod = $registo[0];
$cap = $registo[2];
}
echo"<tr>";
echo"<td>" . $registo[1] . "</td>";
echo"</tr>";
}
echo "</table>";
fclose($file);
}
?>
<?php
$br = "</br>";
if ($_POST) {
echo "Codigo do pais escolhido: " . $cod . "<br>";
echo "Capital: " . $cap . " - " . $registo[1] . "-" . $cod . "<br>";
} else {
?>
<form action="eta15_2teste.php" method="post">
Pais: <input type="text" name="pais"><br>
<input type="Submit" name="enviar" value="Enviar">
</form>
<?php
}
?>
Always return the values of registo[1]
and $registo[0]
of the last line of the file