Skip navigation
Currently Being Moderated

dreamweaver checkbox update problem

Jul 5, 2012 3:44 AM

Hello

 

I have a basic checkbox on a form that is not updating

 

when the box is checked it is updating the PHP DB but when i go back into the form the check box is not showing the correct value

 

 

php is

 

GetSQLValueString(isset($_POST['BankFinCCJ']) ? "true" : "", "defined","'Y'","'N'"),

 

 

 

form value

 

<input type="checkbox" name="BankFinCCJ" <?php if (!(strcmp(htmlentities($row_Recordset1['BankFinCCJ'], ENT_COMPAT, 'utf-8'),"true"))) {echo "checked=\"checked\"";} ?> />

 

 

what am i doing wrong? can anyone help?

 
Replies
  • Currently Being Moderated
    Jul 5, 2012 4:18 AM   in reply to Jonathan Fortis

    Please don't post duplicate threads with what is essentially the same question. I have deleted your original thread.

     

    I think I know what is wrong with your code, but I need to check how GetSQLValueString() handles user-defined values first.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 5, 2012 4:38 AM   in reply to Jonathan Fortis

    Your form should look like this:

     

    <input type="checkbox" name="BankFinCCJ" <?php if (!(strcmp($row_Recordset1['BankFinCCJ'],"Y"))) {echo "checked=\"checked\"";} ?> />

     

    You have misunderstood the following line:

     

    GetSQLValueString(isset($_POST['BankFinCCJ']) ? "true" : "", "defined","'Y'","'N'")

     

    The GetSQLValueString() function takes up to four arguments. The first one is the value, the second is the type. And if the type is "defined", it takes two more arguments: the defined value, and the not-defined value.

     

    The first argument to the function is this:

     

    isset($_POST['BankFinCCJ']) ? "true" : ""

     

    What that means is that if $_POST['BankFinCCJ'] exists, the value passed to GetSQLValueString() is "true". If it doesn't exist, an empty string is passed to the function. The "true" value is used internally by GetSQLValueString(). The actual values are "Y" and "N". That's why you need to test for "Y", and not for "true".

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 5, 2012 4:40 AM   in reply to Jonathan Fortis

    No, I think that my answer above should cover everything.

     

    If you don't get an answer to a post, and think that more information might be needed, just add to the original thread. It makes it much easier for everyone if all related issues are kept in one thread.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 5, 2012 5:23 AM   in reply to Jonathan Fortis

    Yes, it's the value that's stored in the database that matters.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points