Hi Guys,

Iíd REALLY appreciate some advice if possible

Iíve put together a little script here, which adds football goalscorers to a table in my database:

(note clicking the add scorers button adds a dropdown box)

In the SQL table the player_id is the id of the scorer selected from the dropdown and the report_id is the id of an actual match. So for report_id=1 there were two goalscorers for this match.

Now this works fine, but say there were errors in what I entered.

- Ie the wrong player_id was entered as a goalscorer
- or player_id=3 did not actually score and there was one goalscorer

I need to be able to modify this information. So I have three questions:

1) How can I call my page up for report_id=1 ie: http://industrialleague.co.uk/test/g...=1&report_id=1
And there are two scorers boxes dynamically created (rather as one as there are two scorers for this match) which I can then edit data from

2) When I call up the page http://industrialleague.co.uk/test/g...=1&report_id=1 how can I say if there was only one scorer delete a record from the database if there is no value selected in one of the dropdowns while running an update on the other goalscorer as he may be changed?

3) Is there an easier way of recording/editing goalscorers as this way seems very complicated to me!

Hereís my code

PHP Code:

// Start the connection to the database        

// Include functions to get the various values from the dropdown boxes

// Values used for all three tables
$team_id $_GET['team_id'];
$lastinsert '1';
// Values to be inserted into reports table 
$player_id $_POST['player_id'];

// IF i'm not getting data then insert into various tables
// Values to be inserted into goals table                     
foreach($_REQUEST['r'] as $row

mysql_query("INSERT INTO `goals` ( `player_id`,`team_id`, `report_id` ) VALUES ('".$row['player_id']."', '".(int)$_GET['team_id']."', '".$lastinsert."')");

$query_one mysql_query("Update `reports` set player_id='$player_id', team_id='$team_id', report_id='$report_id' where report_id=".$_GET['report_id']);
$msg "Updated";

//End of POST submit


//GET data from Reports Table
$query_one mysql_query("Select * From goals where report_id=".$_GET['report_id']);
$row mysql_fetch_array($query_one);
$report_id $row['report_id'];

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
//Function to dynamically add dropdown boxes
function addRow(form) {
    var span = document.getElementById("ROW").getElementsByTagName('span')[0];
    var obj = span.cloneNode(true);
    var count = form.getElementsByTagName("select").length + 1;
    var oSel=obj.getElementsByTagName('select')[0];
    oSel.setAttribute('tabindex', count);
    oSel.name=oSel.name.split("[1]").join("[" + count + "]")
div {clear:both} 
input { float:left} 
span.next {     

input.inputtext { 
    width: 200px; 
    byear2:2px inset blue; 

<form name="reports" method="post" action="">
    <input name="button" type="button" onClick="addRow(this.form)" value="Add another Scorer">
  <br />
  <br />
<!óDynamic Dropdown boxes start-->
    <div id="ROW">
    <span class="next"> 
<?php $p_id $player_id $player_id ''?>
                    <select class="input" name="r[1]player_id " size="1"  style="width: 145" tabindex="1">
                      <option value="" <?php echo ($p_id == '' 'selected="selected"' ''); ?>>Goalscorer</option>
            foreach (
$type_array as $players
"<option value=\"".$players['player_id']."\"" 
. ($p_id == $players['player_id'] ? 'selected="selected"' ''
<!óDynamic Dropdown boxes end--> <br/><br/>
    <input type="submit" name="Submit" value="Submit" class="button">
    <input type="reset" name="Reset" value="Reset" class="button">
Again. Thanks