Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Senior Member Brak's Avatar
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    3,413
    Member #
    1217
    Liked
    2 times
    Maybe I'm just an idiot (okay, that's not a maybe ).. but I can't figure out how PHP deals with checkboxes for the life of me...

    Basically, got X number of checkboxes of name "id" and value "cc" where cc changes by checkbox... I want to get a list of cc as a string so I can parse it into a SQL... Any help? =x
    Kyle Neath: Rockstar extraordinare
    The blog | The poetry site | The Spore site

  2.  

  3. #2
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Right from my mail script:
    PHP Code:
    function getcheckboxes($prefix)
    // returns a comma-space delimited string of values from $_POST that have a key
    // beginning with prefix followed by an integer.
    {
        
    $a = array();
        foreach (
    $_POST as $key => $value)
        {
            if (
    preg_match("/^$prefix([0-9]+)$/"$key$matches))
            {
                
    array_push($a$matches[1]);
            }
        }
        return 
    implode(", "$a);

    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  4. #3
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Ick, the PHP guys should have made it return a comma-space delimited string from the get-go.

  5. #4
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    PHP doesn't do everything for you...not everybody might like that.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:41 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com