Jump to content

Trouble using <select> in data entry erray


fulcrum2

Recommended Posts

Hi everyone.  I have a data entry page through which I add stats for the russianprospects.com website. It is basically rows of empty fields that I fill in and then submit into the db.   I have an array in place so that I can submit multiple statistic rows at the same time.  To make it easier, I am trying to add a drop down for the player name field (right now I just manually enter the player_id for each row).  I've tried to create the select box code below, which works in some form for single entry, but doesn't seem to work for this erray.  I attached a copy of the most recent version of the page.

 

Could you please take a look and let me know how to fix it? Also - I would be glad to discuss with anyone further over any IM (AIM, ICQ, SKYPE, MSN, Yahoo, etc.). Thank you very much for your time!

----------------DATA ENTRY CODE:--------------------------------------

foreach($stats AS $stat)//Definition of each statistics row of data

{

// THIS IS THE ISSUE RIGHT HERE

//PLAYER DROP DOWN POPULATION CODE

$stats = array( "player_id", "team", "GP", "goals", "assists", "PIM", "plusminus", "jersey_id", "team_id");

 

for ($i = 0; $i < 10; $i++)

{

if ($x=='0'){ // Added this here to assure that this is displayed for the first column across all 10 rows of the data entry sheet

 

$sql_player = "SELECT * FROM player WHERE draft_year=2003 ORDER BY lname";

$result_player = mysql_query($sql_player);

$myrow_player = mysql_fetch_assoc($result_player);

echo '<select name=data[$i][$stat]>';

do {

$lname = $myrow_player ["lname"];

$player_id = $myrow_player ["player_id"];

echo "<option value=\"$player_id\"> $lname $i $stat</option>\n"; //put the $i and $stat in there just to make sure that these show up correctly as they do for the text fields

 

}while ($myrow_player = mysql_fetch_assoc ($result_player));

echo '</select>';

}

//END OF PLAYER DROP DOWN POPULATION CODE

//THIS NEXT PART WORKS WELL

else {

echo "<input type=text name=data[$i][$stat] value=\"\" size=4>";

echo $i;

echo $stat;

}

$x++;

}

 

}

echo "<input type=submit name=submit value=\"update\">";

echo "</form>";

}

 

 

--------------SUBMISSION CODE (goes on top):----------------------

if ( $_POST['submit'] )

{

if ( isset( $_POST['update'] ) )

{

foreach( $_POST['update'] AS $id => $status )

{ // status = "On"

 

$sql =  "INSERT INTO stats_player

(stats_player_id, year,season,league,tour_id,season_part,player_id,team,GP,goals,assists,PIM,plusminus,jersey_id,team_id)

VALUES('',";

$sql .= "'$year','$season','$league','$tour_id','$season_part',";

 

foreach( $_POST['data'][$id] AS $col => $value )

{

if ($col=='0') {$heading="player_id";}

else if ($col=='1') {$heading="team";}

else if ($col=='2') {$heading="GP";}

else if ($col=='3') {$heading="goals";}

else if ($col=='4') {$heading="assists";}

else if ($col=='5') {$heading="PIM";}

else if ($col=='6') {$heading="plusminus";}

else if ($col=='7') {$heading="jersey_id";}

else if ($col=='8') {$heading="team_id";}

echo "$col ---- $value <br>";

$sql .= "'$value',";

}

 

$sql = substr($sql,0,-1); // remove trailing comma

$sql .= ");";

echo $sql."<br><br>";

echo $player_id_internal;

 

----------------OUTPUT-----------------------------

INSERT INTO stats_player (stats_player_id, year,season,league,tour_id,season_part,player_id,team,GP,goals,assists,PIM,plusminus,jersey_id,team_id)

VALUES('','2006','2005-06','NHL','0','1','Pensacola Ice Pirates','42','18','22','30','-','6','7');

--------PROBLEM - completely ignores the select drop down value....--------------------------------

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/119790-trouble-using-in-data-entry-erray/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.