ckevin
June 2nd, 2002, 12:16
I'm new to PHP and writing a PHP program which I want to utilize "for" as follows:
echo "<p>$pti13 ";
for ($i=1; $i < 6; $i++) {
echo "<input type=\"radio\" name=\"pti_index13\" ";
if ($formValues["pti_index13"] == '$i') {
echo "checked ";
}
echo "value=\"$i\"> \n";
}
echo "</p>\n";
However, it can't work properly, while if I don't use "for" (as follows) it can work without problem, so anyone can figure what's wrong with my "for" command?
printf("<p>$pti13 ");
printf("<input type=\"radio\" name=\"pti_index13\" value=\"1\"");
if ($formValues["pti_index13"] == '1') {
printf(" checked");
}
printf("> \n");
printf("<input type=\"radio\" name=\"pti_index13\" value=\"2\"");
if ($formValues["pti_index13"] == '2') {
printf(" checked");
}
printf("> \n");
printf("<input type=\"radio\" name=\"pti_index13\" value=\"3\"");
if ($formValues["pti_index13"] == '3') {
printf(" checked");
}
printf("> \n");
printf("<input type=\"radio\" name=\"pti_index13\" value=\"4\"");
if ($formValues["pti_index13"] == '4') {
printf(" checked");
}
printf("> \n");
printf("<input type=\"radio\" name=\"pti_index13\" value=\"5\"");
if ($formValues["pti_index13"] == '5') {
printf(" checked");
}
printf(">\n");
printf("</p>\n");
Thanks in advance!
echo "<p>$pti13 ";
for ($i=1; $i < 6; $i++) {
echo "<input type=\"radio\" name=\"pti_index13\" ";
if ($formValues["pti_index13"] == '$i') {
echo "checked ";
}
echo "value=\"$i\"> \n";
}
echo "</p>\n";
However, it can't work properly, while if I don't use "for" (as follows) it can work without problem, so anyone can figure what's wrong with my "for" command?
printf("<p>$pti13 ");
printf("<input type=\"radio\" name=\"pti_index13\" value=\"1\"");
if ($formValues["pti_index13"] == '1') {
printf(" checked");
}
printf("> \n");
printf("<input type=\"radio\" name=\"pti_index13\" value=\"2\"");
if ($formValues["pti_index13"] == '2') {
printf(" checked");
}
printf("> \n");
printf("<input type=\"radio\" name=\"pti_index13\" value=\"3\"");
if ($formValues["pti_index13"] == '3') {
printf(" checked");
}
printf("> \n");
printf("<input type=\"radio\" name=\"pti_index13\" value=\"4\"");
if ($formValues["pti_index13"] == '4') {
printf(" checked");
}
printf("> \n");
printf("<input type=\"radio\" name=\"pti_index13\" value=\"5\"");
if ($formValues["pti_index13"] == '5') {
printf(" checked");
}
printf(">\n");
printf("</p>\n");
Thanks in advance!