You are here: Re: Multiple Radio Button Groups - Please Help! :) « PHP Programming Language « IT news, forums, messages
Re: Multiple Radio Button Groups - Please Help! :)

Posted by Tyno Gendo on 04/09/07 11:10

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.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация