rakesh.ravindran Posted July 27, 2007 Share Posted July 27, 2007 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 https://forums.phpfreaks.com/topic/62068-error-in-code-for-creating-a-table-know-a-better-way/ Share on other sites More sharing options...
GingerRobot Posted July 27, 2007 Share Posted July 27, 2007 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. Link to comment https://forums.phpfreaks.com/topic/62068-error-in-code-for-creating-a-table-know-a-better-way/#findComment-309043 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.