# Please Help... Need PHP script to generate table based HTML code...

**URL:** <https://www.phphelp.com/t/please-help-need-php-script-to-generate-table-based-html-code/18913>\
**Category:** General PHP Help\
**Created:** [November 14, 2012, 11:46pm UTC](https://www.phphelp.com/t/please-help-need-php-script-to-generate-table-based-html-code/18913 "2012-11-14T23:46:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://www.phphelp.com/uploads/default/original/2X/2/243e9ed5d93c5653ce3186f18df16e019ce38445.png) [@system](https://www.phphelp.com/u/system)\
**Post date:** [November 14, 2012, 11:46pm UTC](https://www.phphelp.com/t/please-help-need-php-script-to-generate-table-based-html-code/18913/1 "2012-11-14T23:46:46Z")

</div>

My task is create a PHP script that will create an HTML table with the number of rows and columns specified by the user, with the row and column number inside the cell. Any ideas or suggestions are greatly appreciated!

My HTML code is as follows

[code]

Table Creator

### Table Creator

&nbspNumber of rows:&nbsp 1 2 3 4 5 6 7

&nbspNumber of columns:&nbsp 1 2 3 4 5 6 7

  

[/code]

---

<div class="post-metadata">

**Author:** ![wilson382](https://www.phphelp.com/letter_avatar_proxy/v4/letter/w/ed655f/32.png) [@wilson382](https://www.phphelp.com/u/wilson382)\
**Post date:** [November 15, 2012, 6:07pm UTC](https://www.phphelp.com/t/please-help-need-php-script-to-generate-table-based-html-code/18913/2 "2012-11-15T18:07:31Z")

</div>

Make sure sure you put this code in a php file

[php]

\<?php if (isset($\_GET['submit'])) { // set variables from form input $rows = $\_GET['rows']; $columns = $\_GET['columns']; echo "\n"; // loop to create rows for ($r = 1; $r \<= $rows; $r++) { echo "\n"; // loop to create columns for ($c = 1; $c \<= $columns;$c++) { echo " "; } echo " "; } echo "

| &nbsp; |

"; } ?\> Table Creator

### Table Creator

&nbspNumber of rows:&nbsp 1 2 3 4 5 6 7

&nbspNumber of columns:&nbsp 1 2 3 4 5 6 7

  

[/php]

good luck.
