English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Hi,

Im trying to make an if statement that will set a string depending on the value of another string, I have this so far but it doesnt appear to work...

if($titleflag) == 1) {
$checked = " checked";
}
else {
$checked = "not checked";
}

2007-08-06 10:44:04 · 5 answers · asked by jeff lemon 1 in Computers & Internet Programming & Design

chipchamp, you have not changed anything!

2007-08-06 10:54:50 · update #1

5 answers

Change it to this and see if it works:

if ($titleflag == 1) {
$checked = " checked";
}
else {
$checked = "not checked";
}

That should work... If it doesn't, make sure that you have the variables named correctly...

And if that still doesn't work, where it says $titleflag == 1, you might want to change the 1 to "1", but that's as a last chance idea...

EDIT: I did change something. You put a ) right after $titleflag

2007-08-06 10:51:45 · answer #1 · answered by ChipChamp 4 · 0 0

do a switch statement instead

switch($titleflag){
case '1':
$checked = 'checked';
break;
default:
$checked = 'not checked';
break;
}

but to be truly helpful be a little more descriptive on what you are trying to accomplish. in the switch statement just put case as whatever number or 'string' you want.

2007-08-06 18:16:44 · answer #2 · answered by Big D 4 · 0 0

if($titleflag) == 1)

you have 1 opening bracket

and 2 closing brackets

remove the closing bracket after $titleflag


and PHP
stands for PHP hypertext preprocessor
http://ie.php.net/manual/en/faq.general.php

2007-08-08 18:00:31 · answer #3 · answered by mixturenumber1 4 · 0 0

Php = Philipine peso "jokes!!!

Uhhmmm! i remember my System Analysis and Design, Logic Design and Switching, Data Structure and Design, Pascal programming uffff!!!

2007-08-06 17:57:52 · answer #4 · answered by C H R I S 5 · 0 2

Syntax error:
if($titleflag) == 1) {
must be:
if ($titleflag == 1) {
-> parenthesis after flag) !
You should get an error, actually...

2007-08-07 03:07:41 · answer #5 · answered by just "JR" 7 · 1 1

fedest.com, questions and answers