POST and variable question

I have two pages.
One that echos
for every entry in a table on my database. (id starts at 1 and auto increments)
this form actions to my second page that needs the values from these boxes.
so I have a loop that reads the table until it runs out of data

[SQL stuff]
[Loop]
$id=mysql_result($result,$x,“id”);
$newvar = $_POST[’$id’];
++$x;
[End of Loop]

I’ve done some outputs to find the problem
and $id is working correctly but $newvar isn’t getting a value from POST.

:o I hope you can understand my awful example

Are you aware that $newvar is being overwritten with every loop? ;)

Take the single quote out of the $_POST index. It’s being treated as a literal.

Wrong:

$newvar = $_POST['$id'];

Correct:

$newvar = $_POST[$id];

And like the post above said, you’re overwriting $newvar in the loop so make sure your using it in the loop also.

Sponsor our Newsletter | Privacy Policy | Terms of Service