
October 6th, 2005, 01:18 PM
|
|
Registered User
|
|
Join Date: Jan 2004
Posts: 9
Time spent in forums: 1 h 54 m 31 sec
Reputation Power: 0
|
|
|
PHP & MySQL Logic query....
Hi,
I have a site (PHP/MySQL) that uses authentication (username/password) to allow access to content (on a 'userlevel' basis as well as name basis). That all works fine.
However I have a bit of a logic query. What I want to do is the following, in a statement:
If a users 'level' = 30, get all results from database (except for those marked 'private') unless for those marked 'private', the value of field 'ownerid' (in that or those records) is equal to the current 'userid' or is an admin userlevel. Otherwise, just display all the database item not marked 'private'
The code I have so far is:
Code:
if ($suserlevel>=30 OR $suserlevel==99)
{
$result = mysql_query("select * from table_items where item_category = $item_category AND item_userid= $suserid [....this is where I need to put the unless clause.....] ORDER by item_id DESC");
}else{
etc.
I'm really stuck...do I need to use some form of complicate JOIN command or do I need to write more if/else statements?
Kind Regards
David
|