Código PHP:
<body>
<?
//Miro si ha sido enviado el formulario
if (isset ($_POST['fil']) && isset ($_POST['col'])) {
$fil=$_POST["fil"];
$col=$_POST["col"];
} else {
$fil=0;
$col=0;
}
?>
<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>
<?
//Me aseguro q los numeros indicados son mayores q 0
if ($col>0 && $fil>0) {
$num=1;
//Empiezo a recorrer las filas
for ($i=1;$i<=$fil;$i++) {
?>
<tr>
<?php
//Se recorren las columnas dentro de la fila
for ($j=1;$j<=$col;$j++) {
?>
<td><?php echo $num; ?></td>
<?php
$num++;
}
?>
</tr>
<?php
}
} else {
//El error que quieras mostrar, x ejemplo
echo "Las columnas y filas introducidas deben ser superiores a 0.";
}
?>
</table>
</form>
</body>