Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

dreamweaver checkbox update problem

Engaged ,
Jul 05, 2012 Jul 05, 2012

Copy link to clipboard

Copied

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?

TOPICS
Server side applications

Views

1.1K
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jul 05, 2012 Jul 05, 2012

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

...

Votes

Translate
LEGEND ,
Jul 05, 2012 Jul 05, 2012

Copy link to clipboard

Copied

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.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 05, 2012 Jul 05, 2012

Copy link to clipboard

Copied

sorry for the duplicate post, i made one late last night and wasnt sure i covered what i was trying to get across

do you need anything from me?

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 05, 2012 Jul 05, 2012

Copy link to clipboard

Copied

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.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 05, 2012 Jul 05, 2012

Copy link to clipboard

Copied

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".

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 05, 2012 Jul 05, 2012

Copy link to clipboard

Copied

I understand, so basically what ever value you are using to store in the DB is the value that needs to be checked so we are using y and N if we were storing truw and flase we would check these values?

thats was a great help thank you

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 05, 2012 Jul 05, 2012

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines