Jump to content

error in code for creating a table- know a better way?


Recommended Posts

guys...this is a code to get some info for creating a table from a form and store it in an array,and later on,try and display the array!(this is only part of the code)

this is not working....cud neone find d errors?

is dere a better way to do the same operation?

<?php

session_start();

session_register('no_fields');

?>

<?php

                   if(isset($_POST['posted']))

                    {

 

                        $no_fields=$_SESSION['no_fields'];

                        echo $_POST['f[0]'];  

 

                             for($i=0;$i<$no_fields;++$i)       /*getting value from the form fields into variables*/

                              {

                                $field_name[$i]=$_POST['f[$i]'];

                                $type[$i]=$_POST['t[$i]'];

                                $length[$i]=$_POST['l[$i]'];

                              }

                           

                             for($i=0;$i<$no_fields;++$i)       /*test-trying to display the fields!*/

                               {

                                echo $field_name[$i];

                               }

 

                    }  

 

 

 

                  if (!isset($_POST['posted']))

                    {

                           

                      $no_fields=2;          

                      for($i=0;$i<$no_fields;++$i)         /*displaying form according to number of fields*/

                        {

                          echo"

                               <form method=post action=sample.php>

                               field_no:$i<input type=text name=f[$i]>

                               type:<input type=text name=t[$i]>

                               length:<input type=number name=l[$i]>  

                               <br>

                              ";

                        }

                          echo"

                               <input type=submit value=submit>

                               <input type=hidden name=posted>

                               </form>      

                              ";

                    }      

 

?>

Could you tell us what you mean when you say its not working. Do you get an error message? What does it do at the moment?

 

Also, it would help people greatly if you surround your code in

 tags - without the spaces. Makes it much easier to read.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.