Add more button is not recording to Db

raihan 25 Feb, 2013
Hi, I have added 'Add more' button in my form. It's working properly. But not updating the table. When I tried to 'Create Table' it's showing error like I attached. I have used the code as below, from some FAQ:
<?php
// set the total count
$count = 5;
for ( $i = 1; $i <= $count; $i++ ) {
  // add classes which will let us identify the inputs to hide
  if ( $i == 1 ) {
    $class = 'show_me';
  } else {
    $class = 'hide_me';
  }
  // add the 'Add one' buttons (but not to the last set)
  if ( $i < $count ) {
    $j = $i+1;
    $button = "<div><input type='button' name='addone_{$j}' id='addone_{$j}' value='Add one' class='add_one' /></div>";
  } else {
    $button = "";
  }
  // add the inputs with a little ChronoForms styling
  echo "<div id='recipient_{$i}' class='{$class}' >
  <div class='multiline_start'>
    <label>Name</label>
    <input type='text' name='recipient[{$i}][name]' id='recipient_{$i}_name' />
  </div>
  <div class='multiline_add'>
    <label>Address</label>
    <input type='text' name='recipient[{$i}][address]' id='recipient_{$i}_address' />
  </div>
  <div class='clear' ></div>
  {$button}
</div>";
}
?>


Please help!!! Thaning you.
GreyHead 26 Feb, 2013
Hi Raihan,

That's correct. You can't use those names as column names in your table. Especially because there may be several different values that you want to save.

As I think I've said before you need to work out how you want to save this data and set up the table(s) to match.

Bob
This topic is locked and no more replies can be posted.