FORMULARIO
Código PHP:
<table>
<tr>
<td>
INSTRUCCIONES
</td>
</tr>
<tr>
<td>
seleccione las divisas que quiere poner en la tabla:<br>
<form method="post" action="generar_tabla.php" name="generate_table">
<?php
include_once "includes/connexio.php";
$table="divisa_codigos";
$name="view";
$field1="codigo";
$field2="nombre_esp";
$gbp="GBP";
$cad="CAD";
$eur="EUR";
$jpy="JPY";
$chf="CHF";
$usd="USD";
echo "<select size=7 multiple=\"\" name=\"$name\" onChange=\"Actualiza1(this.form,this.value)\">";
$sql_query=mysql_query("select $field1,$field2 from $table order by $field2",$id_connect);
if($row = mysql_fetch_array($sql_query))
{
while($row = mysql_fetch_array($sql_query))
{
$val=$row["$field1"];
if($row["$field1"]==$gbp || $row["$field1"]==$cad || $row["$field1"]==$eur || $row["$field1"]==$jpy ||
$row["$field1"]==$chf || $row["$field1"]==$usd)
{
echo "<option value=\"$gbp\" selected=\"\" ";
echo "<option value=\"$cad\" selected=\"\" ";
echo "<option value=\"$eur\" selected=\"\" ";
echo "<option value=\"$jpy\" selected=\"\" ";
echo "<option value=\"$chf\" selected=\"\" ";
echo "<option value=\"$usd\" selected=\"\" ";
}
else
{
echo "<option value=\"$val\" ";
}
echo ">". $row["$field2"] .".". $row["$field1"] ."</option>";
}
}
else
{
echo "NO DATA - $table - ";
}
echo "</select>";
?>
</td>
</tr>
<tr>
<td>
<input name="ok" type="submit" value="Crear tabla"><br>
<input name="del" type="reset" value="Borrar">
</form>
</td>
</tr>
</table>
Código PHP:
<?php
$monedas=$_POST['generate_table'];
$va=1;
echo "<table border='1'>";
echo "<tr>";
echo "<td>";
foreach($monedas as $value){
echo '<td>'.$value.'</td>';
}
echo "</td>";
echo "</tr>";
foreach($monedas as $value){
echo '<tr><td>'.$value.'</td>';
foreach($monedas as $valor){
echo '<td><font color=#0000FF>'.$va.'</font></td>';
}
}
echo'</tr>';
echo "</table>";
?>