one form, multiple records

wimste 30 Apr, 2012
Hello again,

I've got this huge problem, at least, it is huge for me 🙂 .
I want to load a form containing data from multiple tables but I should load multiple records. Meaning, when I click the submit button, I want the form to reload or maybe use a mulitpage and go to the next record.
Saying, I've got for 4 tables:
- jos_seizoen: cf_id,seizoen
- jos_spelers: cf_id,alias
- jos_kalender: cf_id, datum, seizoen (referring to the cf_id in jos_seizoen), spelers (array of ids reffering to jos_spelers)
- jos_scores: cf_id,seizoenid (ref cf_id in jos_seizoen), datumid (ref cf_id in jos_kalender), spelerid (ref cf_id in jos_spelers), game1, game2, game3

I've created a view of the tabel jos_kalender which show an HTML table with 'datum, spelers, {link to input score}, {link to edit the row}, {link to delete the row}
Now when I click the link to input the score, I want to open a form which loads: seizoenid, datumid, spelerid of the chosen html row. !BUT! 🙂 I first want to load the spelerid of the player who is listed first in the HTML row. When clicking the submit button, I want to reload the form, but with the spelerid of the next player,etc...

I've attached an MS Word document with multiple screenshots, hoping that it will help to explain my problem.[attachment=0]Issue multiple records-one form.docx[/attachment]

Already big thanks for all your help!!!

Kr,

Wim
GreyHead 30 Apr, 2012
Hi Wim,

A bit hard to get my head round all of this in a couple of minutes but I think I'd probably save an array of players' names (or ids) into the User Session when the table is loaded. Then I'd look it up when submit is Clicked get the first name from the array to display the Player info, and save the rest of the array without that record. This way each click of submit would get the next player.

Bob
wimste 03 May, 2012
Hi Bob,

Thank you very very much for your tip!!! I managed to work it out with the help of the array.
The solution i used is

- The link for the HTML table is like:
http://localhost/beersgoot/index.php/index.php?option=com_chronoforms&chronoform=scoreperdag&datumid=1&spelers=12,7,10,11

- Then I have a DB Record Loader which has the following where statement:
<?php
$datumid= JRequest::getString('datumid', '', 'get');
$datumid= urldecode($datumid);
echo "`datumid` = '$datumid' " ;
?>
AND
<?php
$spelers= JRequest::getString('spelers', '', 'get');
$players= explode(",",$spelers);
foreach ($players as $speler):
echo "`spelerid` = '$speler'" ;
break;
endforeach;
?>

This loads the details just as it should:
[attachment=0]form.JPG[/attachment]
And then when the onsubmit event is fired, I use the simple DB save action and next if have this custom code:
<?php
$players= explode(",",$form->data['spelers']);
unset($players[0]);
$spelers=implode(",",$players);
if ($spelers):
$url='index.php?option=com_chronoforms&chronoform=scoreperdag&datumid='.$form->data['datumid'].'&spelers='.$spelers;
else:
$url='index.php/kalender';
endif;
?>
<script>window.location="<?php echo $url;?>";</script>


This looks to work like a charm!!!
Maybe there is an easier way of doing this, but for now this will do just fine :wink:
Thanks a lot for getting me 'on track' as this was the last step to perform for my site. Pretty soon it will be online and then I'll by you a beer!

Kr,

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