I've tried and tried, but I can't get this to work. I use Joomla and I have 2 articles/pages, one for edit and one for posting the form. I have a database with all the matches for the World Cup coming up and I want my users to bet on the matches.
I have 2 tables - one with all matches like this (named vm_kampe
):
|id |hhold |uhold |res |
|1 |Rusland |Saudi |NULL |
|2 |Egypten |Uruguay |NULL |
... and so on
and the other table is my coupon where my bets are stored(named vm_207
where 207 is my user-id, so every user gets its own table):
|id |resu |
|1 |2-1 |
|2 |1-3 |
... and so on.
So the id in vm_207
should connect to the id of the match in vm_kampe
.
So I want a page, where I can update my bets, so I have this:
foreach($results as $row){
echo '<div class="vm_kupon_row">
<div class="vm_id"><input type="hidden" name="kampid[]" value="'.$row->id.'"></div>
<div class="vm_kampe">'.$row->hhold.' - '.$row->uhold.'</div>
<div class="vm_result"><input class="vm_resultat" type="text" name="resultat[]" placeholder="X-X" value="'.$row->resu.'"></div>
</div>';
};
echo '<input type="submit" class="godkend-vm-kupon" name="submit" value="Godkend">';
That calls out all matches with an input field where the value is selected from my table vm_207
and it works. Now, if I change something I want to update, the form action calls this page:
$jinput = JFactory::getApplication()->input;
$kampid = $jinput->get('$kampid');
$resultat = $jinput->get('$resultat', 'string');
$fields = array(
$db->quoteName('resu') . ' = ' . $db->quote($resultat)
);
$conditions = array(
$db->quoteName('id') . '=' . $kampid
);
$query->update($db->quoteName('vm_207'))->set($fields)->where($conditions);
But it won't update anything.
Please help me make this work. If you need any more details just say so :)
Thanks!