Abersparky wrote:
How do I get the radio name to automatically increment?? (and by the
way I know I totally butchered the name value that's there lol)
if ($w_row['vis']=='Y') {
print '<input name="{$w_row["comment_id"]}" type="radio" checked
value="Y">';
} else {
print '<input name="{$w_row["comment_id"]}" type="radio" value="Y">';
}
if ($w_row['vis']=='N') {
print '<input name="{$w_row["comment_id"]}" type="radio" checked
value="N">';
} else {
print '<input name="{$w_row["comment_id"]}" type="radio" value="N">';
}
You are using single quotes on the print, that will mean that the names
will literally be "{$w_row...}" I think by just glancing at it, but
assuming your comment_id is an INT AUTO_NUMBER PRIMARY KEY then your
code should be fine if you hadn't used single quotes. You don't need to
write your whole INPUT twice, just set a value for 'checked' to be
inserted into the input code, I'd do something like:
$w_row['vis'] == 'Y' ? $checked='checked="checked"' : $checked="";
echo '<input name="comment' . $w_row["comment_id"] . '" type="radio"
' . $checked . ' />';
Or if you don't like the 3step if (tertiary or whatever..) ...
$checked = '';
if ( $w_row['vis'] == 'Y' ) {
$checked='checked="checked"';
}
echo '<input name="comment' . $w_row["comment_id"] . '" type="radio"
' . $checked . ' />';
hope that helps. you should end up with radio's called comment1,
comment2, comment3 etc. depending on your comment_id field's primary key
values.