Thanks again Aidos
My head is a bit melted over this now…I have a piece of php that handles input but I’m not sure how to modify it to work with your code above…
My input page has a form which the user can dynamically add fields but starts out with at least one record for player
Name:
<select name="player[1][userid]" id="player[1][userid]" class="playerInput">
<option value=""></option>
........
<select name="player[1][hours]" id="player[1][hours]">
.........
<select name="player[1][minutes]" id="player[1][minutes]">
This produces the following query string when the form is submitted (for 3 players)
http://…&player[1][userid]=1&player[1][hours]=2&player[1][minutes]=15&player[2][userid]=7&player[2][hours]=3&player[2][minutes]=30&player[3][userid]=11&player[3][hours]=1&player[3][minutes]=45
I use the following php to loop through this query string and insert into database (for each player I insert their Id, Hours, Minutes)
$sql = 'Insert into '.$tbl_name.' (date,playerid,hours,mins) values ';
foreach ($_GET as $key => $value) {
if($key != 'submit'){
if(is_array($value)) {
foreach ($value as $iKey => $iValue) {
$sql = $sql . '('.$date.',';
foreach ($iValue as $xKey => $xValue) {
$sql = $sql.$xValue;
if ( $xValue !== end($iValue))
$sql = $sql.',';
}
$sql = $sql.')';
if ( $iValue !== end($value))
$sql = $sql.',';
}
}
}
}
Apologies if this has drifted off the original question or is in the wrong forum.
I’m not sure how I can convert this on the way into the database using the above foreach loops.
At the moment my table has id, date, playerid, hours, mins but I can combine hours and mins, as I said previously to mins.
thanks again for all your help…