Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Brainstorming PHP code
PostPosted: February 19th, 2013, 10:39 am 
Rsbandb Donor
Offline

Joined: October 16th, 2005, 3:14 pm
Posts: 4731
Location: Kasnas City us
RS Name: Azek
RS Status: P2P
So I am working on my senior project. It is a database for my University.

Anyway, the program I am using doesn't let me hide values from the public. For instance there will be a picture up and I want to hide the price for public users, but not for admin/contributor.

I know a little PHP (I mean I ve dont like 20 tutorial videos) is there an easy way to add a line of code that is something like

if (admin = true)
show
else
hide

something like that?

_________________
Image


Top
 Profile  
 
 Post subject: Register and login to get these in-post ads to disappear
PostPosted: February 19th, 2013, 10:39 am 
Rsbandb Donor

Joined: September 9th, 2004, 1:47am
Posts: 9047
Location: In your web browserz


Top
  
 
 Post subject: Re: Brainstorming PHP code
PostPosted: February 20th, 2013, 4:56 pm 
Site Owner
Offline

Joined: September 9th, 2004, 9:26 am
Posts: 6886
Location: Wild Rose Country ca
RS Name: shane12088
RS Status: P2P
You've pretty much got it:
Code:
if ($user->isAdmin() == true) { // or just use if ($user->isAdmin()) -- shorthand works too
// Do something here
}
else {
// Do something else
}


The boolean logic in PHP is pretty much the same as you'd find in other languages like C or Java. You just need to get your variables that you're working with and make it so.

_________________


Top
 Profile  
 
 Post subject: Re: Brainstorming PHP code
PostPosted: February 20th, 2013, 10:10 pm 
Rsbandb Donor
Offline

Joined: October 16th, 2005, 3:14 pm
Posts: 4731
Location: Kasnas City us
RS Name: Azek
RS Status: P2P
Shane wrote:
You've pretty much got it:
Code:
if ($user->isAdmin() == true) { // or just use if ($user->isAdmin()) -- shorthand works too
// Do something here
}
else {
// Do something else
}


The boolean logic in PHP is pretty much the same as you'd find in other languages like C or Java. You just need to get your variables that you're working with and make it so.



Awesome, thanks.

I am going to start messing with it next week so I will update then.

_________________
Image


Top
 Profile  
 
Display posts from previous:  Sort by  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to: