views:

52

answers:

1

Im trying to dynmically generate a table that has a radio button per row whose value is set to the ID field of a SQL table. Im not sure how I can reference this value using CGI radio_group. In my research radio_group uses an associate array, however if I convert the SQL query to an associative array the values wont match up since there are more than 2 tables in the query. If possible I'd like to avoid a second SQL call:

use CGI;
use DateTime::Format::MySQL;

$epoch = DateTime->now(time_zone=>"America/New_York");
$fmtnow = DateTime::Format::MySQL->format_datetime($epoch);
$iasql = qq { select * from alert where endtime > '$fmtnow'};
$iaqry = $iadb->prepare($iasql);
$iaqry->execute() || die "Fail $DBI::errstr"
print $query->start_table({-border=>1, -cellpadding =>1});
while(@iarows = $iaqry->fetchrow_array()) {
    print $query->Tr(print $query->td([print $query->radio_group('iaselect',\@iarows[0]),'@iarows[1]','@iarows[2]','@iarows[3]','@iarows[4]','@iarows[5]']));
}
print $query->end_table();
A: 

Yeah I think Im gonna nix the the CGI radio button method for this part and just have it print print "<input type="radio">;, it works that way. I was only attempting to use this method because I hadn't realized there are start_div and end_div methods. Prior to finding those I thought this was my only way of achieving the radio buttons inside of the q->div() container.

I excluded the Div portion of the code because it didn't seem relevent.

Please edit your question, rather than adding a non-answer.
Ether