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>      

                              ";

                    }      

 

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.