foreach ($graphEdge as $graphNode) {
echo
"<div class='form-check mb-3'>" .
"<input type='radio' name='fb_profile' class='form-check-input' value='".$graphNode['name']."'>" .
"<img class='mr-2' src='" . $graphNode['picture']['url'] . "'>" .
"<label class='form-check-label' for='fb_profile'>" .
$graphNode['name'] . '</label>' .
"</div>";
echo "<input type='hidden' name='fb_access_token' value='" . $graphNode['access_token'] . "'>";
echo "<input type='hidden' name='fb_id' value='" . $graphNode['id'] . "'>";
}
正如标题所示,我有3个名为“ fb_id”的隐藏输入,当我在表单中进行POST时将始终检索最后的隐藏输入,而fb_access_token将始终正确进行POST。
答案 0 :(得分:0)
好的。从对话中可以看出,您想要获取取决于radio
的值。
您可以这样操作:
foreach ($graphEdge as $graphNode) {
echo
"<div class='form-check mb-3'>" .
"<input type='radio' name='fb_profile' class='form-check-input' value='".$graphNode['name']."'>" .
"<img class='mr-2' src='" . $graphNode['picture']['url'] . "'>" .
"<label class='form-check-label' for='fb_profile'>" .
$graphNode['name'] . '</label>' .
"</div>";
echo "<input type='hidden' name='fb_access_token[".$graphNode['name']."]' value='" . $graphNode['access_token'] . "'>";
echo "<input type='hidden' name='fb_id[".$graphNode['name']."]' value='" . $graphNode['id'] . "'>";
}
然后您可以像这样通过radio
值获取选定的值(假设您的表单发送POST请求):
$profile = $_POST['fb_profile'];
$accessToken = $_POST['fb_access_token'][$profile];
$id = $_POST['fb_id'][$profile];