/    Sign up×
Community /Pin to ProfileBookmark

if else statement with update function

I am trying to run a function that will update one column with either a 1 or a 0

function directoryent(){
$a=”1″;
$b=”0″;
$result = mysql_query (“SELECT directory FROM clubauth WHERE authorised = 1 and clubid=$_SESSION[‘clubid’]”);

if ($a){
echo ‘You are currently a member of the online directory. Click update to be removed’ ;
else
if ($b){
echo ‘You are not a member of the onine directory. Click update to be entered’;
}
}

The idea is that it checks the database, gives a message and then provides an update button to update the column based on the users id.
Any idea on how i should go about it?

Thanks

Dave

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@sushiApr 25.2008 — [code=php]function directoryent(){
$result = mysql_query ("SELECT userID, authorized FROM clubauth WHERE clubid=$_SESSION['clubid']");
while($user = mysql_fetch_object($result)){
if($user->authorized==1){
echo 'You are currently a member of the online directory. Click update to be removed' ;
//here either add a form (or a link to an update page) including the user data and <input type='hidden' value='0' name='whatAction'/>
//so you know it's either 1, or 0 the new value.
}else{
echo 'You are not a member of the onine directory. Click update to be entered';
//same here.
}
}
}
[/code]


something like that..
Copy linkTweet thisAlerts:
@dag78authorApr 25.2008 — It works to a degree, i have update buttons now set up as a separate funciton, however the messages does not change when you click update, but the table updates no problem
Copy linkTweet thisAlerts:
@dag78authorApr 25.2008 — fixed it i missed an elelment out
×

Success!

Help @dag78 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.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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