for loop for dynamic form var names
Posted: Thu Dec 23, 2004 3:20 pm
I have done this in the past and it worked beautifully, however now when I try to include a dynamic name for one of my POST vars, It's not coming up with a value:
here's what I have:
and as I said before, I did something almost identical to this and it worked fine...see below:
now though, for the first one, when I echo $_POST['crs$i']...I get nothing. If I hardcode the value for $i in there (ex: "1") then it works just fine.
can someone assist here?
I'm at a complete loss???
thx,
Burr
here's what I have:
Code: Select all
<?php
for($i=1;$i<$_POST['scrollpos']+1;$i++){
$sql = "INSERT INTO My_Table VALUES (".$m_id.",".$_POST['crs$i'].",'y',0,'blah',0)";
$result = mysql_query($sql, $db)
or trigger_error(mysql_error(),E_USER_ERROR);
}
?>Code: Select all
<?php
for($j=1;$j<=$getpl["tournamentplayernum"];$j++){
mysql_query("insert into tour_players (
tournamentid,
teamid,
playername,
ipadd,
todaysdate
)
values
(
".$_GET["id"].",
".$_POST["teamid"].",
'".mysql_escape_string($_POST["player$j"])."',
'".$_SERVER["REMOTE_ADDR"]."',
now()
)
")
or trigger_error("could not insert to players table".mysql_error(),E_USER_ERROR);
}
?>can someone assist here?
I'm at a complete loss???
thx,
Burr