I have a form which displays x amount of fights to bet on, it's a bit tacky at the moment because I can't get my head around the logic and design I should use regarding sending the data to my submit page.
The variables I need to pass I as follows:
fightId
fighterId1, betAmount
fighterId2, betAmount
The form now is just a hidden field with fightId and a text input field for betting amount.
So if betAmount for that fightId is set, it should add that bet to the db, and if not it should just ignore that fight.
What I've done now is to have a radio button next to the input text field just to be able to pass the variables I need, but that feels redundant and not very user friendly.
Removing the radio button, the form is as follows:
Code: Select all
<input type='hidden' name='fightId[]' value='4' />
<input type="text" name="bet4[4]" value="" class='text' id='bet4[4]' />
<input type="text" name="bet4[3]" value="" class='text' id='bet4[3]' />
bet4[3] is bet for fightId 4 and fighterId 3, value is what the user is betting.
Then on the submit page I loop through the fightId array:
Code: Select all
foreach($_POST['fightId'] as $id) {
if(isset($_POST['bet'.$id])) {
}
}
I need to store the key in order to be able to insert fightId, fighterId, betAmount to the DB table.