我正在尝试将一个数字附加到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>' ;
}
答案 0 :(得分:0)
想出来。这是解决方案:
错误:value="'.$_SESSION["fname_'.$i.'"].'"
右:value="'.$_SESSION["fname_".$i].'" />