Thread: Split categories in half.
Results 1 to 5 of 5
Related
-
script only half runs when called from php Forum: CGI Perl Forum
Replies: 2 -
[split] PHP upload script. Forum: PHP Forum
Replies: 3 -
Half the forum under lock and key???????? Forum: General Discussion
Replies: 2
-
04-17-2005, 05:14 PM #1
Split categories in half.
I have a CGI script that lets people sign up, and one of the questions ask that it pick from a list of 22 things or so, on what they think there good at, what i wantted to do is, have the list split, so that after every 11 categories or so, it would start from a new line so there wouldent by one LONG list (incause we add more.
right now the code is:
<b>$category_name:</b><br>
EOF
if($allow_multiple_cat eq 1) {
if($max_categories) {
print "<small>(You can make up to $max_categories selections.)</small><br>\n";
} else {
print "<small>(You can make multiple selections.)</small><br>\n";
}
foreach $cat(@freelancer_categories) {
print "<input type=\"checkbox\" name=\"category\" value=\"$cat\"> $cat<br>\n";
}
print "<p>\n";
} else {
print "<select name=\"category\" size=\"1\">\n";
foreach $cat(@freelancer_categories) {
print " <option value=\"$cat\">$cat</option>\n";
}
print "</select>\n";
print "<p>\n";
}
so was wondering if anyone here could help?
also i tried to search, but dident really know what to search for, and when though a couple of page, but again dident really know what i was search for, so i just decided to post it.
Thanks in advnace for any help given.
Please let me know if you need more information.
Thanks.
Mike.
-
04-28-2005, 02:13 PM #2
Re: Split categories in half.
i am having trubble understanding what exactly you want. from what i can understand you are trying to split the catagories in half, but why? if they are in an array you can simply use the split function or the shift and/or pop. if they are in a string put them into an array. but please refine more, then i can help you out more!
-
05-02-2005, 11:44 PM #3
Re: Split categories in half.
Hey,
thank you for your reply, heres the thing, right now when i add a catagory though the admin area, it saved in data.cgi or whatever then when you goto the page, it takes all the caragorys and puts them in a line stright down, i want it so it puts 10 stright down, and it puts another 10 next to it.
here what i have right now: http://www.letemscript.com/cgi-bin/freelancers/buyers.cgi?new=project
if you look under the heading "Jobs" you can see that there are 22 jobs to chose from, now what i want is that it geos down 11 of theos (upto "JSP" and then go back to the top, (from where .net started)
Let me know if that helps a bit, if not let me know and ill show you a before and after picture in html format
Let me know.
Thanks.
-
05-03-2005, 09:11 AM #4
Re: Split categories in half.
Code:print "<table>\n"; for(i=0; $i<=$#freelancer_categories; $i++){ if($i % 11 = 0){ print "</td><td>\n"; } print "<td><input type=\"checkbox\" name=\"category\" value=\"$freelancer_categories[$i]\"> $freelancer_categories[$i]<br>\n"; } print "</td></table>";
I hope that works,
-ALL
-
05-03-2005, 04:47 PM #5
Re: Split categories in half.
sorry, i can't edit my post, but here is better code:
Code:print "<table>\n"; for(i=0; $i<=$#freelancer_categories; $i++){ if($i % 11 == 0){ print "</td><td>\n"; } print "<input type=\"checkbox\" name=\"category\" value=\"$freelancer_categories[$i]\"> $freelancer_categories[$i]<br>\n"; } if($#freelancer_categories % 11 == 0){ print "</table>\n"; }else{ print "</td></table>\n"; }
*If the number goes into 11 without a remander, it will not put two </td>'s
*And i messed up by putting "=" insted of "=="
Cloudjiffy- PaaS for Developers
10-05-2020, 12:30 AM in Web Hosting Forum