Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2003

    Question Unanswered: Problem using checkbox assign in Array with if condition

    hi there,

    i have form with multiple checkbox and i assign as array

    <input type="checkbox" name="see[]" value="Tour Package Info">
    <input type="checkbox" name="see[]" value="Forum"><input type="text" name="see_dll_info">
    <input type="checkbox" name="see[]" value="Web"><input type="text" name="see_dll">

    but some of the check box with text field. so user can select multiple values and if the checkbox value provide textfield user have to fill in.

    so extract the array when form submmited

    $see = $_POST["see"];
    $see_dll = $_POST["see_dll"];
    $see_dll_info = $_POST["see_dll_info"];

    while(list($key,$val) = @each ($see)){
    if ($val = 'web'){
    $see_dll_txt = $see_dll;
    if ($val = 'Forum'){
    $see_dll_txt = $see_dll_info;

    print("The is $key and the value is - $val ($see_dll_txt) <br>");

    but it only print out this first value like :

    The is 0 and the value is - Forum(testing)
    The is 1 and the value is - Web(testing)

    is there any solution or idea for this problem..


  2. #2
    Join Date
    Apr 2005
    Baltimore, MD
    Can't really understand what the problem is, but here's a few tips.

    For comparison, use the '==' operator, not '='.

    Also, an easier way to spit out the array is like this:

    PHP Code:
    foreach ($_GET['see'] as $k => $v) {
    'Key = ' $k '; Value = ' $v;

  3. #3
    Join Date
    Mar 2003

    Thumbs up

    thanks jfulton, actually my problem is to solve comparison in looping array. your tips its right to extract the array and i just need to add condition to array value.

    foreach ($_GET['see'] as $k => $v) {
    echo 'Key = ' . $k . '; Value = ' . $v;

    if ($v == 'Tours') {
    $txt = $_POST['txt_1'];
    }elseif ($v == 'Tours') {
    $txt = $_POST['txt_2'];



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts