开发者

PHP - Form made from a loop forgets its values

There's a form in PHP script, which is made from while loop. Like:

$z = 1;
While ($x < $y)
{
    $reminder = $_POST["entry$开发者_StackOverflow中文版z"];
    echo "<input type='text' name='entry".$z."' value='".$reminder."' size='50' />"
    $z++;
}

My script remembers other values, when you change the pages, but not that from the loop. Does someone know why? Have a solution? Thanks!


Do you have defined values for the $x and the $y in the loop?

Also close the echo with a ;


The text box will have the value you set with the value attribute, in your case $reminder. You could set the default value to something from the $_REQUEST array instead which will contain the form values from last time the form was submitted.

Something like $_REQUEST['entry'.$z] instead of $reminder would do it.

EDIT: didn't see the line above the textbox creation where you define that variable. Just change it to $_POST['entry'.$z]

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜