Jump to content

Recommended Posts

hi all i have to make script that pulls from mysql and showing the level of this admin

 

like this :

 

<?php
function ($admin) {
$sql = mysql_query("select * from people where name ='$admin' ") or die("".mysql_error());
   if ( mysql_num_rows($sql) ) {
  fetch = mysql_fetch_array($sql) 
}

   if ($fetch['level] == 1 ) {
   // here the problem 
}elseif($fetch[level == 2 ){
// here too 
}elseif($fetch[level] == 3 ) {
// here 
}
  }

 

so what can i defined in the comments area above to call this function later and authorized admins ?

if you noticed that i have a lot of levels !

 

thanks for any suggestions

Link to comment
https://forums.phpfreaks.com/topic/82763-admin-levels/
Share on other sites

<?php
if ($fetch['level] == 1 ) {
   // here the problem 
}elseif($fetch[level == 2 ){
// here too 
}elseif($fetch[level] == 3 ) {
// here 
}
  }

 

notice this difference:

 

<?php
if ($fetch['level'] == 1 ) {
   // here the problem 
}elseif($fetch['level'] == 2 ){
// here too 
}elseif($fetch['level'] == 3 ) {
// here 
}
  }

the colour of the script gives away something is not closed in your attempt

it should be ['level']

 

Link to comment
https://forums.phpfreaks.com/topic/82763-admin-levels/#findComment-420929
Share on other sites

ah , i'm so sorry about this code i just typed it know

 

but the idea is : it dosent matter know from where to get these levels but i want to something like defining value like this :

 

 

   <?php 

   function auth($someone) {
     global $ptab;
	 $admin_sql = mysql_query("select * from $ptab where name = '$someone' ");
		   
		  if (mysql_num_rows($admin_sql)) {
		   $fetch = mysql_fetch_array($admin_sql);
		   }
			  
			   if ( $fetch['lvl'] == 1 ) {
			 // do something
			   }elseif($fetch['lvl'] == 2 ) {
			// do something
			   }elseif($fetch['lvl'] == 3 ) {
                                // do something
			   }

			   
          } // end function auth ;
?>
         
  // so i dont know how to call this function !!!!!!!!!
  // but this is the idea i want the authorization in this way 
// thanks for your replay  

Link to comment
https://forums.phpfreaks.com/topic/82763-admin-levels/#findComment-420932
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.