SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru
    Join Date
    Nov 2008
    Posts
    622
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Checkbox checked with database value

    hi all

    I have 3 checkboxes whose values are getting stored in the database with a comma separator.

    Code:
    <input name="color[]" type="checkbox" value="red" id="red" />red  
    <input name="color[]" type="checkbox" value="blue" id="blue" />blue 
    <input name="color[]" type="checkbox" value="green" id="green" />green
    values getting stored with comma separator

    Code:
    red, blue, green
    now i want to show the checkboxes as "checked" to show the customer as which colors they chose lasttime when they submitted the form.

    How can i make it possible ?

    If it is possible without the comma separator then i can remove the comma.

    vineet

  2. #2
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,178
    Mentioned
    63 Post(s)
    Tagged
    2 Thread(s)
    Your storing the data incorrectly for this.

    PHP: serialize - Manual

    and

    PHP: unserialize - Manual

    This will allow you to store an array in the column that can be easily manipulated for what you want to do.


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
  •