I have a program that uploads a .csv file of golf scores. upon upload the data from the file is diplayed in the form of a html table in the browser. the code for this is shown below.
echo '<div class="tablediv"><table><form method="post" action="new.php" >';
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
if($ctr ==1)
{
echo '<tr>';
echo "<th>" . $data[3] . "</th><th>" . $data[4] .
"</th><th> " . $data[5] . "</th><th> " . $data[6].
"</th><th>" . $data[7] ."</th><th> Prize </th>" ;
echo '</tr>';
$ctr++ ;
}
else if ($ctr > 1)
{
echo '<tr>';
echo "<td>" .$data[9] . "</td><td>" . $data[10] .
"</td><td>" . $data[11] . "</td><td> " . $data[12]. "</td><td>" . $data[13] . "</td><td><select name='dropdown'>
<option value='empty'>None Allocated</option>
<option value='firstprize'>First Prize</option>
<option value='secondprize'>Second Prize</option>
<option value='thirdprize'>Third Prize</option>
</select></td>";
echo '</tr>';
}
}
echo '<input type="submit" name="submit" value="Submit" class="submit1" /></form></table></div></br>';
fclose($handle);
}
once a user has uploaded the file and it is diplayed I want the user to be able to allocate a prize via the dropdown list and then, once this is done the data can be commited to a database. what i need to do is basically get the selected prize position also and commit that to the database along with the other data. im just not too sure how to get at the selected value in the dropdown list. would the best way to do this be to use PHP simple HTML DOM parser? or does anyone know of an easier way. Thanks a lot for your help in advance!
the initial upload of the file looks like below. last column being the dropdownlist
Player name H'cap Score Front Back Prize
name 18 66 33.0 33.0 none allocated
name 11 67 33.5 33.5 none allocated
name 4 67 33.0 34.0 none allocated
name 12 67 31.0 36.0 none allocated
name 11 68 34.5 33.5 none allocated
name 6 68 34.0 34.0 none allocated
name 19 68 31.5 36.5 none allocated
name 11 69 36.5 32.5 none allocated
name 11 69 33.5 35.5 none allocated
my solution was this. this way i can get the post data on the new.php page by using var_dump($_POST). I create another counter “$counter2″ and initialize it to 1. then in append the counter to the dropdownlist name ” and var_dump($_POST) gives me an output like
this
here are the changes i made to the function.
this is a pretty sloppy solution i know. so any other solutions you may have for this would be appreciated. thanks.