39 users online (0 members and 39 guests)  


  Results 1 to 5 of 5

Related

  1. script only half runs when called from php    Forum: CGI Perl Forum
    Replies: 2
  2. [split] PHP upload script.    Forum: PHP Forum
    Replies: 3
  3. Half the forum under lock and key????????    Forum: General Discussion
    Replies: 2
  1. #1
    mp04's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2005
    Location
    Atlanta, GA
    Posts
    3

    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";
    }
    as you can see it allows my users to chose as many or up to the amount set by the admin, and right now, there no code in there for halfing the list of categories

    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.

  2. #2
    ALL's Avatar
    Super Dooper Nerd

    Status
    Offline
    Join Date
    Feb 2005
    Location
    localhost
    Posts
    382

    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!

  3. #3
    mp04's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2005
    Location
    Atlanta, GA
    Posts
    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.

  4. #4
    ALL's Avatar
    Super Dooper Nerd

    Status
    Offline
    Join Date
    Feb 2005
    Location
    localhost
    Posts
    382

    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 cant test this code because my computer with cgi/perl on it is getting repaired, but if it doesnt work, play around with it to see what you can do. but what it does is put them into a table and then after every 11 entries it makes a new collom.

    I hope that works,

    -ALL

  5. #5
    ALL's Avatar
    Super Dooper Nerd

    Status
    Offline
    Join Date
    Feb 2005
    Location
    localhost
    Posts
    382

    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";
    }
    Things that I improved
    *If the number goes into 11 without a remander, it will not put two </td>'s
    *And i messed up by putting "=" insted of "=="



Tags for this Thread