hy,
in this post these are not full codes, just tips!
And not tested๐ So please don't say parse errors here ๐
use array in fieldnames
for example:
Player <input type='text' name='players[]' size='35' value=''>
Why do you need to add a default value to this field? i don't suggest that.
And you have to declare a variable name in the sex dropdown ๐
<select name="sex[]"><option value='1'>Male</option><option value='2'>Female</option></select><br>
have you heard about for cycle?
<?php
for($i=0;$i<15;$i=$i+1)
{
print "Player ".($i+1) . ": \r";
print ' <input type="text" name="players[]" size="35" value="">
<select name="sex[]">
<option value="1">Male</option>
<option value="2">Female</option>
</select><br />';
}
?>
on your process code you can use this for cycle to get the values,
<?php
/* arrays first element starts from 0 */
for($i=0;$i<15;$i=$i+1)
{
if(!empty($_POST["players"][$i]))
{
print "Player ".($i+1) . ": \r";
print $_POST["players"][$i] . "<br />";
print $_POST["sex"][$i]. "<br />";
print $_POST["finalscore"];
$errors[]= add_new_sex_game($_POST["game_ID"],$_POST["players"][$i],$_POST["sex"][$i],$_POST["finalscore"]);
/*and you can call the insert function to the database.
AND CALL THE mysql_real_escape_string function while you insert
something into the database table...!
you can do that inside a function!
And chech all the required values inside that function, and gives back an error
message using return...!
*/
}
else
$errors[]="Player ".($i+1)." is empty..."; //lets create an error array
}
if(isset($errors))
{
// lets inform the user that some players are missing
foreach($errors AS $row)
print "$row <br />";
die();
}
?>
1 if male, 2 if female , and this value will get into the database.