checkbox to mysql blues - Page 2
Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21

Thread: checkbox to mysql blues

  1. #16
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,420
    No, because a field defined as ENUM('no', 'yes') would have values of 1 and 2 for 'no' and 'yes', respectively. A value of 0 (or the empty string, '') is more like an error/undefined/NULL value. If you wanted to use an ENUM column, then you'd want to make sure that you're setting $survey to either 'yes' or 'no' - not a numeric value.

  2. #17
    Member
    Join Date
    Jan 2012
    Posts
    47

    ok

    Okay so I went to set ENUM ('1', '2')

    and changed to 'yes' and 'no' in my php code

    PHP Code:
      <input name="survey" type="checkbox" value="<?php $survey = isset($_POST['survey']) ? 'yes' 'no'?>" />

  3. #18
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,420
    Quote Originally Posted by cybereclipse View Post
    Okay so I went to set ENUM ('1', '2')
    Why would you do that? The string '1' and the string '2' (note those are different than the numbers one and two) aren't very descriptive at all.

    If you walked up to me and asked me if I liked the color green, and I responded with '2', would you understand what I meant?

    Quote Originally Posted by cybereclipse View Post
    and changed to 'yes' and 'no' in my php code
    ... which adds further confusion into the mix, because now your PHP code doesn't match what the DB is expecting.

  4. #19
    Member
    Join Date
    Jan 2012
    Posts
    47

    well

    well show me how its done.

  5. #20
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,420
    I already did that back in post #7 of this thread.

  6. #21
    Senior Member traq's Avatar
    Join Date
    Jun 2011
    Location
    so.Cal
    Posts
    949
    agreed - stick with BOOL.
    ENUM complicates things needlessly and makes the code more fragile.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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