/    Sign up×
Community /Pin to ProfileBookmark

Is there a way to make this code and where the else is

make it else and ($user_data[‘eventType’]) != ‘Wedding’

So basically, if Photoweb is being used a message will appear, but if it is not being used and your event is a birthday, it will say You will not be using photoweb, but if the event is a wedding and photoweb is not being used then nothing will happen.

[code=php]
<?php if($user_data[‘photoWeb’]){ ?>
You will be using photoweb services.
<?php }else{ ?>
You will not be using photoweb services.
<?php } ?>
[/code]

to post a comment
PHP

18 Comments(s)

Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYMar 01.2006 — Do you mean something like [url=http://php.net/elseif]elseif[/url] ?
Copy linkTweet thisAlerts:
@kattenMar 01.2006 — elseif($user_data['eventType'] != 'wedding')

is what i under stood from your post
Copy linkTweet thisAlerts:
@bokehMar 01.2006 — [code=php]
<?php if($user_data['photoWeb']){ ?>
You will be using photoweb services.
<?php }else{ ?>
You will not be using photoweb services.
<?php } ?>
[/code]
[/QUOTE]
Why do you keep opening and closing PHP tags?
Copy linkTweet thisAlerts:
@comptech520authorMar 01.2006 — This is what I have, I know I am missing a semi-colon or two. Can you please help me sort this out?

[code=php]
<?php if($user_data['photoWeb']){
You will be using photoweb services.
}
elseif($user_data['eventType'] != 'wedding') {
echo('')
}
?>
[/code]
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYMar 01.2006 — is this what you are looking for`?
[code=php]
<?php
if($user_data['photoWeb']){
switch($user_data['eventType']){
case "birthday":
# using photoweb and event is birthday
break;
case "wedding":
# using photoweb and event is wedding
break;
default:
# using photoweb
break;
}
}else{
# not using photoweb
}
?>
[/code]


if not, i'd suggest that you explain what you need better
Copy linkTweet thisAlerts:
@bokehMar 01.2006 — is this what you are looking for`?[/QUOTE]That's the exact same answer I gave him yesterday in a parallel thread.
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYMar 01.2006 — huh? didn't see he cross posted
Copy linkTweet thisAlerts:
@comptech520authorMar 01.2006 — When I use this statement and photoweb = 0 and eventType is not Equal to wedding, the "You will not be using photoweb services" line does not appear

How come? Any ideas?

[code=php]
<?php
if($user_data['photoWeb'] ='1') {
echo 'You will be using photoweb services.';
}elseif($user_data['photoWeb'] ='0' && $user_data['eventType'] != 'wedding') {
echo 'You will not be using photoweb services.';
}
?>
[/code]
Copy linkTweet thisAlerts:
@NogDogMar 01.2006 — You must use [b][color=blue]==[/color][/b] for "equal to" comparisons, not a single equal sign (which is for assignment). You really need to make that a habit, or you'll find yourself tearing your hair out. As I stated before, if you put the literal value of the comparison on the left side and the variable on the right, then at least you'll get an error message when you forget:
[code=php]
if('1' == $user_data['photoWeb]) {
[/code]
Copy linkTweet thisAlerts:
@SheldonMar 01.2006 — try two = symbols and or not and

}elseif($user_data['photoWeb'] == '0' || $user_data['eventType'] != 'wedding') {
Copy linkTweet thisAlerts:
@comptech520authorMar 01.2006 — if the photoweb field in my DB only stores a 0 or a 1, what should I format the field as?
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYMar 01.2006 — --edit: i'm late
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYMar 01.2006 — --edit: i'm late

eww..sorry..damn, instead of editing i pressed quote!

nogdog can you delete them?
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYMar 01.2006 — You must use [b][color=blue]==[/color][/b] for "equal to" comparisons, not a single equal sign (which is for assignment). You really need to make that a habit, or you'll find yourself tearing your hair out. As I stated before, if you put the literal value of the comparison on the left side and the variable on the right, then at least you'll get an error message when you forget:
[code=php]
if('1' == $user_data['photoWeb]) {
[/code]
[/QUOTE]


<i>
</i>if('1' == $user_data['photoWeb[B][COLOR=Red]'[/COLOR][/B]]) {
?
Copy linkTweet thisAlerts:
@bokehMar 01.2006 — You must use [b][color=blue]==[/color][/b] for "equal to" comparisons, [/QUOTE]I also told him that yesterday in his parallel thread.
Copy linkTweet thisAlerts:
@SheldonMar 01.2006 — There are 3 people with at least two threads all asking the same questions over and over, its getting rediculas
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYMar 01.2006 — It's crazy, i'm getting completely confused, erm..which thread are we talking about?

and shawnmicheal, stop cross posting, bad boy!
Copy linkTweet thisAlerts:
@comptech520authorMar 01.2006 — Thanks for the == tips guys. Sometimes I need to be told a couple times to make it sink in.

The trouble I am still having with this is when the event type = wedding and photoweb = 0 (no) the message displays as you are using photoweb.

If wedding = yes and photoweb = 0 I don't want anything to show up.

[code=php]
<?php
if('1' == $user_data['photoWeb']) {
echo 'You will be using photoweb services.';
}elseif($user_data['eventType'] != 'Wedding' && '0' == $user_data['photoWeb']) {
echo 'You will not be using photoweb services.';
}
?>
[/code]
×

Success!

Help @comptech520 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...