It seems like your logic is messed up, and you are unable to use a for statement as a conditional statement which is why you are getting the fatal error. I tried to manipulate the logic below, which made more sense to me.
I tried to make coments to explain what the sections are doing in the processing section.
PHP Code:
<html> <head> <title>form</title> <style type="text/css"> body {background-color:yellow} label {display:block} </style> </head> <body> <?php if (empty($_POST)) { ?> <form name="input" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <label for="rows">Number of rows: <input type="text" name="rows" id="rows" /></label> <label for="columns">Number of columns: <input type="text" name="columns" id="columns" /></label> <label for="starting">Starting number: <input type="text" name="starting" id="starting" /></label> <label for="display">Display count: <input type="text" name="display" id="display" /></label> <label for="skip">Multiply skip count by: <input type="text" name="skip" id="skip" /></label> <label for="order-asc"><input type="radio" name="order" id="order-asc" value="asc" /> Increment</label> <label for="order-desc"><input type="radio" name="order" id="order-desc" value="desc" /> Decrement</label> <input type="submit" value="Submit" /> </form> <?php } else { // Prepare input: $rows = ($_POST['rows'] > 1) ? (int)$_POST['rows'] : 1; $columns = ($_POST['columns'] > 1) ? (int)$_POST['columns'] : 1; $display = ($_POST['display'] > 1) ? (int)$_POST['display'] : 1; $skip = ($_POST['skip'] > 1) ? (int)$_POST['skip'] : 1; $starting = (int)$_POST['starting']; $starting = (int)$_POST['starting']; // Create number sequence array: $numbering = array(); // Increment or decrement logic if ($_POST['order'] == 'desc') $skip = -$skip; // Numbering logic for ($num = $starting, $i = 0; $i < $display; $i++, $num += $skip) { $numbering[] = $num; } ?> <table border="1" width="100%"> <?php // Rows for ($r = 0; $r < $rows; $r++) { ?> <tr> <?php // Columns for ($c = 0; $c < $columns; $c++) { ?> <td><?php echo implode('<br />', $numbering); ?></td> <?php } ?> </tr> <?php } ?> </table> <?php } ?> </body> </html>
__________________
<mgraphic /> - I don't have a solution but I admire the problem.
|