0

我正在尝试将一个数字附加到 PHP$_SESSION变量的末尾,但由于某种原因,该数字没有附加。这是我遇到问题的代码部分:

value="'.$_SESSION["fname_'.$i.'"].'"

$i包含我试图附加到$_SESSION变量的数字。有什么建议么?谢谢

//Loop through the number of stored in $_SESSION['management-count'] and print out that many sections
    $_SESSION['management-member-template'] = '' ;
    for ($i = 1; $i <= $_SESSION['management-count']; $i++) {
        $_SESSION['management-member-template'] .= '
        <li class="">
            <div class="heading-line">
                <h5>Member <span class="num">'.$i.'</span></h5>
                <a href="#" class="btn-remove"><span>Remove Member</span></a>
            </div>
            <div class="text-frame">
                <p>Would you like to use a previously entered individual?</p>
            </div>
            <div class="controls">
                <div class="radio-line" id="radio-'.$i.'">
                    <input type="radio" id="member_'.$i.'_1" name="member_'.$i.'" checked="checked"  />
                    <label for="member_'.$i.'_1">'.$_SESSION['legal-first-name'].' '.$_SESSION['legal-last-name'].', '.$_SESSION['legal-address'].' '.$_SESSION['legal-address-2'].', '.$_SESSION['legal-city'].', '.$_SESSION['legal-state'].' '.$_SESSION['legal-zip'].'</label>
                </div>
                <div class="radio-line" id="rad-'.$i.'">
                    <input type="radio" id="member_'.$i.'_2" name="member_'.$i.'" title="new-address" />
                    <label for="member_'.$i.'_2">No, enter a new name</label>
                </div>
            </div>
            <div class="new-address hidden" id="new-address-'.$i.'">
                <div class="form-row">
                    <div class="item">
                        <label>First Name <span>*</span></label>
                        <div class="text">
                            <input type="text" name="member['.$i.'][fname]" value="'.$_SESSION["fname_'.$i.'"].'" />
                        </div>
                    </div>
                    <div class="item">
                        <label>Last Name <span>*</span></label>
                        <div class="text">
                            <input type="text" name="member['.$i.'][lname]" value="'.$_SESSION["fname_'.$i.'"].'" />
                        </div>
                    </div>
                </div>
            </div>
        </li>
        <script type="text/javascript">
        $(document).ready(function () {
            $("#rad-'.$i.'").click(function() {
                $("#new-address-'.$i.'").removeClass("hidden");  
            });
            $("#radio-'.$i.'").click(function() {
                $("#new-address-'.$i.'").addClass("hidden");  
            });
        });
        </script>' ;
    }
4

1 回答 1

0

弄清楚了。这是解决方案:

错误的:value="'.$_SESSION["fname_'.$i.'"].'"

正确的: value="'.$_SESSION["fname_".$i].'" />

于 2012-12-05T03:57:13.570 回答