Runescape Bits & Bytes
https://www.rsbandb.com/forums/

Brainstorming PHP code
https://www.rsbandb.com/forums/viewtopic.php?f=38&t=84394
Page 1 of 1

Author:  Ranging God [ February 19th, 2013, 10:39 am ]
Post subject:  Brainstorming PHP code

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?

Author:  Adbot [ February 19th, 2013, 10:39 am ]
Post subject:  Register and login to get these in-post ads to disappear


Author:  Shane [ February 20th, 2013, 4:56 pm ]
Post subject:  Re: Brainstorming PHP code

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.

Author:  Ranging God [ February 20th, 2013, 10:10 pm ]
Post subject:  Re: Brainstorming PHP code

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.

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/