Insert selected value in array / drop down into database

1

Next: I use RSForm! and instead of using the Mapping functionality it offers, I script the Update user has already registered) and Insert (if you do not have one). This script is inserted in the "Script called on form process" part. Here I do the tests and I update or I insert the data in the bank. My problem is this: I have 1 drop down on the form whose items are assigned through an array, as per the code below:

*//<code>
$items = array('','1|Solteiro','2|Casado','3|Marital','4|Desquitado','5|Divorciado','6|Viúvo','7|Outros');
$db = JFactory::getDbo();
$idUsuarioLogado = JFactory::getUser()->id;
$db->setQuery("SELECT estado_civil FROM minha_tabela WHERE id_usuario = $idUsuarioLogado");
$result = $db->loadObject();

foreach ($items as $chave => $item) {
  if($result->estado_civil == $chave){
    $items[$chave] = $item."[c]";
  }else{
    $items[$chave] = $item;
  }
}
$items = implode("\n", $items);
return $items;
//</code>*

When the user is logged in and has already registered, he / she brings the data from the correct bank and populates the drop down. When it is not, it fills in the list for the user to choose.

The problem is: how do I insert the selected value into the database in the drop down?

Because if I just get like this: $estado_civil = $_POST['form']['estadocivil']; It returns an array and does not insert anything into the database.

Does anyone have a light?

PS: When I use Mapping and do an INSERT , it usually inserts the drop down data into the database. I do not use Mapping because I need to test if I'm going to give an UPDATE or an INSERT in the database. And I have not found out if this test can be done using this functionality.

    
asked by anonymous 05.08.2014 / 15:45

1 answer

1

Everything indicates that RSForm! transforms the select value into an array where the first element is the option code and the second is the option itself. In this case, just take the information you want in:

$_POST['form']['estadocivil'][1]

Assuming that "1" is the index corresponding to the value.

    
05.08.2014 / 21:30