Reputation: 679
I have creating project in joomla, for get user entry from textbox and store into session and session assinged for variables,
I was set session variable , but i dont know how to get and store into database, because the values may be n Numbers based on user entry
my view is
<td><input type="text" name="lmno[]1" id="lmno[]1" value=""></td>
<td><input type="text" name="pieceno[]1" id="pieceno[]1" value=""></td>
<td><input type="text" name="aepi[]1" id="aepi[]1" value=""></td>
<td><input type="text" name="appi[]1" id="appi[]1" value=""></td>
<td><input type="text" name="awid[]1" id="awid[]1" value=""></td>
<td><input type="text" name="offermts[]1" id="offermts[]1" value=""></td>
<td><input type="text" name="passmts[]1" id="passmts[]1" value=""></td>
<td><input type="text" name="rejmts[]1" id="rejmts[]1" value=""></td>
<td><input type="text" name="lessmts[]1" id="lessmts[]1" value=""></td>
<td><input type="text" name="points[]1" id="points[]1" value=""></td>
<td><input type="text" name="pts1[]1" id="pts1[]1" value=""></td>
<td><input type="text" name="remarks[]1" id="remarks[]1"value=""></td>
<td><input type='button' id='addButton' value="Add" >
and model code is
$data= $app->input->getArray($_POST);
$session = JFactory::getSession();
$session->set('lmno', $data['lmno']);
$session->set('pieceno', $data['pieceno']);
$session->set('aepi', $data['aepi']);
$session->set('awid', $data['awid']);
$session->set('offermts', $data['offermts']);
$session->set('passmts', $data['passmts']);
$session->set('rejmts', $data['rejmts']);
$session->set('lessmts', $data['lessmts']);
$session->set('points', $data['points']);
$session->set('pts1', $data['pts1']);
$session->set('remarks', $data['remarks']);
How to these variable value and store into joomla databse
guide me finish this task....
Upvotes: 1
Views: 799
Reputation: 138
To get the value from the session,
$session = JFactory::getSession();
$lmno = $session->get('lmno', '');
$pieceno = $session->get('pieceno', '');
In order to save to the database using JTable, you can use the following syntax.
$row = JTable::getInstance('User', 'JTable');
if(!$row->save($data)){
throw new Exception($row->getError(), 500);
}
Upvotes: 1