Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
The feature that is NOT working on one of them is the sorter. Since you can create as many links or referers as you want, it prints out all the current ones in a form consisting of radio boxes from 1- (total number of items in this area) so you can chose which order they'll be displayed in on the site.
Ie.
From here, the admin can change the order in how this displays on the site any way they want.ID | radio buttons to select order --------------------------- link1 1(*) 2() 3() 4() link2 1() 2(*) 3() 4() link3 1() 2() 3(*) 4() link4 1() 2() 3() 4(*)
This code was developed by a programmer a number of years ago and I can't figure it out. Can someone take a look at the 2 snippets below and tell me why the first one DOES work for the links but the one for the referrers prints out
Here's the LINKS section that prints out the form correctlyID | radio buttons to select order --------------------------- link1 1() 1() 1() 1(*) link2 1() 1() 1() 1(*) link3 1() 1() 1() 1(*) link4 1() 1() 1() 1(*)
Here's the code for the referer section that prints out all 1s instead of the correct sortable form.print "<center><table border='1'>\n"; print "<tr><td colspan=\"2\"><center><b>Adjust link di +splay order</b></center></td></tr>\n"; print "<form action='process.cgi' method='post'>\n"; print "<input type='hidden' name='section' value='links'>\n"; print "<input type='hidden' name='action' value='link_order'>\ +n"; $sql = "SELECT * FROM $links_table ORDER BY link_order ASC"; $sth = $dbh->prepare($sql); $sth->execute; $orders_list = join(":", @orders); $id_list = join(":", @ids); print "<input type='hidden' name='orders_list' value='$orders_ +list'>\n"; print "<input type='hidden' name='link_id_list' value='$id_lis +t'>\n"; while ($i = $sth->fetchrow_hashref) { my $id = $$i{"id"}; my $name = $$i{"name"}; my $order = $$i{"link_order"}; print "<tr><td>$name</td>\n"; print "<td>\n"; foreach $t_order (@orders) { print "$t_order <input type='radio' name='order_" . $i +d . "' value='$t_order'"; if ($order eq $t_order) { print " checked" } print ">"; } print "</td></tr>\n"; } print "<tr><td colspan=\"2\"><center><input type='subm +it'></center>\n"; print "</table></center>\n"; print "</form>\n";
print "<b><i>Adjust referrers display order</i></b><br>\n"; print "<table border='1'>\n"; print "<form action='process.cgi' method='post'>\n"; print "<input type='hidden' name='section' value='referrers'>\ +n"; print "<input type='hidden' name='action' value='link_order'>\ +n"; $sql = "SELECT * FROM $referrers_table ORDER BY link_order ASC +"; $sth = $dbh->prepare($sql); $sth->execute; $orders_list = join(":", @orders); $id_list = join(":", @ids); print "<input type='hidden' name='orders_list' value='$orders_ +list'>\n"; print "<input type='hidden' name='link_id_list' value='$id_lis +t'>\n"; while ($i = $sth->fetchrow_hashref) { my $id = $$i{"id"}; my $name = $$i{"name"}; my $order = $$i{"link_order"}; print "<tr><td>$name</td>\n"; print "<td>\n"; foreach $t_order (@orders) { print "$t_order <input type='radio' name='order_" . $i +d . "' value='$t_order'"; if ($order eq $t_order) { print " checked" } print ">"; } print "</td></tr>\n"; } print "</table>\n"; print "<input type='submit'>\n"; print "</form></center>\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: dynamic radio sorting
by Anonymous Monk on Jun 29, 2005 at 19:05 UTC | |
by sapnac (Beadle) on Jun 29, 2005 at 19:25 UTC |