Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/07/2006, 20:34
Avatar de Chileno82
Chileno82
 
Fecha de Ingreso: marzo-2003
Ubicación: Santiago de Chile
Mensajes: 40
Antigüedad: 21 años, 1 mes
Puntos: 0
Exclamación Matriz- Array

Hola maestros, tengo un problema con este ejercicio que sè que es bàsico pero no lo he podido arreglar, el ejemplo consiste en hacer un formulario que me pide el ingreso de un numero de filas y de columnas, la idea es que llene automaticamente las tablas.. por ejemplo:

a)FILAS :2 ; COLUMNAS: 5

RESULTADO:

12345
678910

b)FILAS 4; COLUMNAS :10

12345678910
11121314151617181920
21222324252627282930
31323334353637383940

Acà les dejo el còdigo ojala me puedan ayudar con este problemita, saludos queridos maestros.


<body>
<?
$fil=$_POST["fil"];
$col=$_POST["col"];

?>



<form name="form1" method="post" action="matrix.php">
<table width="58%" border="1" align="center" bordercolor="#FFFFFF" bgcolor="#0000FF">
<tr>
<td width="8%" bgcolor="#0000FF"><div align="center">Filas</div></td>
<td width="26%"><input name="fil" type="text" id="fil" value="<?echo $fil?>"></td>
<td width="11%" bgcolor="#0000CC">columnas</td>
<td width="26%"><input name="col" type="text" id="col" value="<?echo $col?>"></td>
<td width="29%"><input name="calcular" type="submit" id="calcular" value="calcular"></td>
</tr>
</table>
<table border=1>
<?
$c=1;
while($c <= $col) {
echo "<td>". $c ."</td>\n";
if($c == $cv) {
echo "<tr>";
$num = $c+round($col/$fil);
}
if($num) { $cv = $num; } else { $cv = round($col/$fil); }
$c++;
}
?>
</table>
</form>
</body>