Results 1 to 4 of 4

Thread: Checkbox array storage and retrieval in Php

  1. #1
    Join Date
    Jul 2009
    Posts
    49

    Checkbox array storage and retrieval in Php

    I am facing some issues in Php over here i am trying to store the contents of check boxes in a field in a mysql database and retrieve them later. Can anyone provide me with the code i have try to use the below code

    Code:
    <input type="checkbox" name="days[]" class="other" value="Monday1" /> 
       <label class="left">Monday1</label> <br /> 
       <input type="checkbox" name="days[]" class="other" value="Tuesday1" /> 
       <label class="left">Tuesday1</label> <br /> 
       <input type="checkbox" name="days[]" class="other" value="Wednesday1" /> 
       <label class="left">Wednesday1</label> <br /> 
       <input type="checkbox" name="days[]" class="other" value="Thursday1" /> 
       <label class="left">Thursday1</label> <br /> 
       <input type="checkbox" name="days[]" class="other" value="Friday1" /> 
       <label class="left">Friday1</label> <br /> 
       <input type="checkbox" name="days[]" class="other" value="Saturday1" /> 
       <label class="left">Saturday1</label> <br /> 
       <input type="checkbox" name="days[]" class="other" value="Sunday1" /> 
       <label class="left">Sunday1</label> <br />

  2. #2
    Join Date
    Apr 2008
    Posts
    2,005

    Checkbox array storage and retrieval in Php

    Try to use the following code hope it works for you

    HTML Code:
    $b=0;
    foreach ($days_as $value){
    $b=$b+1;
    }
    for($j=0;$j<$b;$j++) 
    {
    echo $days[$b];
    echo "<br/>";
    }

  3. #3
    Join Date
    May 2008
    Posts
    2,297

    Checkbox array storage and retrieval in Php

    When i am trying to store array i guess there should be a comma -delimated string of values but with the code it appears to have the value of array which i think that implode is not working that is $_POST['days'] array stored not as a string of values separated by commas.

  4. #4
    Join Date
    Jan 2008
    Posts
    1,521

    Checkbox array storage and retrieval in Php

    Try to use the below code and i am sure you would be able to have implode with this code

    PHP Code:
    $days_array1 = array("");
    foreach (
    $_POST['days_1'] as $val1){
        
    $days_array[] = $val1
    }
    $days_1 implode(",",$days_array1); 

Similar Threads

  1. Replies: 4
    Last Post: 29-05-2011, 10:27 AM
  2. Replies: 3
    Last Post: 06-03-2011, 12:18 AM
  3. Storage Array SSD(Intel x25-m; OCZ)
    By Nalini_sh in forum Hardware Peripherals
    Replies: 3
    Last Post: 11-11-2009, 12:39 PM
  4. ISO image retrieval
    By sdwivedi in forum Windows Software
    Replies: 3
    Last Post: 25-05-2009, 03:37 PM
  5. Connecting Ms Excel to vb.net retrieval & storage of data?
    By Chandrakant81 in forum Software Development
    Replies: 5
    Last Post: 21-02-2009, 10:45 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,691,137.04378 seconds with 16 queries