penguin0 Posted May 21, 2007 Share Posted May 21, 2007 I am having trouble getting mysql to only pull where admin = 1, users = 1, pageman = 1. I want it to pull the menu, and check the value of the view field it would say somthing like "admin". Then in the users table it says admin and either there is a 1 or 0. $result = mysql_query( "SELECT * FROM users WHERE session = '$userssession'" ); $num_rows = mysql_num_rows( $result ); while ( $a_row = mysql_fetch_array( $result ) ) { $usersid = $a_row['id']; $usersname = $a_row['name']; $usersposition = $a_row['position']; $usersusername = $a_row['username']; $usersemail = $a_row['email']; $userscreated = $a_row['created']; $usersidle = $a_row['idle']; $online = $a_row['online']; $admin = $a_row['admin']; $pageman = $a_row['pageman']; $userman = $a_row['userman']; $rateman = $a_row['rateman']; $menuman = $a_row['menuman']; $users = $a_row['users']; } $result = mysql_query( "SELECT number, name, link, view, isparent, private FROM menu WHERE private = 1 ORDER BY position" ); $num_rows = mysql_num_rows( $result ); print "<table width=\"156\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"ptable\">"; while ( $row = mysql_fetch_array( $result ) ) { $mnumber = $row['number']; $mname = $row['name']; $mlink = $row['link']; $misparent = $row['isparent']; $mprivate = $row['private']; if ($misparent == "0") { $starttag = "<td class=\"off\" onmouseover=\"this.className=\" onmouseout=\"this.className=\" height=\"30\" align=\"left\" valign=\"middle\"><a href=\"/romac$mlink\" class=\"left_menu_text\">"; $endtag = "</a></td></tr>"; } else { $starttag = "<TH><br>"; $endtag = "<br><br></TH></tr>"; } $menu_block .= " <tr>$starttag$mname$endtag"; } ?> <? echo "$menu_block"; ?> there is the code, I was trying to do something like this: $result = mysql_query( "SELECT number, name, link, view, isparent, private FROM menu WHERE private = 1 && view='admin or pageman' ORDER BY position" ); $num_rows = mysql_num_rows( $result ); To explain some of the variables: ($pageman, $userman, $rateman, $menuman, $users) are all tinyint (1)s in the user table, stating if the user can view somthing or not. in the menu table the view field will have values like menuman, admin, users and so on. Quote Link to comment https://forums.phpfreaks.com/topic/52276-solved-using-permissions-to-hide-parts-of-a-menu/ Share on other sites More sharing options...
penguin0 Posted May 21, 2007 Author Share Posted May 21, 2007 is there a problem with the amount of information I put here? Quote Link to comment https://forums.phpfreaks.com/topic/52276-solved-using-permissions-to-hide-parts-of-a-menu/#findComment-258348 Share on other sites More sharing options...
penguin0 Posted May 22, 2007 Author Share Posted May 22, 2007 I am trying to get 2 databases to talk where view (field in 'menu') = just text like:admin or rateman and if $admin ( I know how to call this for the current user) = 1 then $viewable = admin, and if $viewable = $view then show that row in the database.. well my problem is I dont know how to do a check (if statement I know that), to see if view = (these are fields in the table 'users') $admin $pageman $userman $rateman $menuman $users Quote Link to comment https://forums.phpfreaks.com/topic/52276-solved-using-permissions-to-hide-parts-of-a-menu/#findComment-258733 Share on other sites More sharing options...
penguin0 Posted June 2, 2007 Author Share Posted June 2, 2007 I got this to work the way I was trying all along. if ($admin == "1") { $vadmin = "admin"; } if ($pageman == "1") { $vpageman = "pageman"; } if ($userman == "1") { $vuserman = "userman"; } if ($rateman == "1") { $vrateman = "rateman"; } if ($menuman == "1") { $vmenuman = "menuman"; } if ($users == "1") { $vusers = "users"; } $result = mysql_query( "SELECT number, name, link, view, isparent, private FROM menu WHERE private = 1 && view = '$vadmin' || private = 1 && view = '$vpageman' || private = 1 && view = '$vuserman' || private = 1 && view = '$vrateman' || private = 1 && view = '$vmenuman' || private = 1 && view = '$vusers' ORDER BY position" ); $num_rows = mysql_num_rows( $result ); Quote Link to comment https://forums.phpfreaks.com/topic/52276-solved-using-permissions-to-hide-parts-of-a-menu/#findComment-266998 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.