Jump to content

showing other members profile


almightyegg

Recommended Posts

Don't call your variable $GET as it's too much like $_GET which is a predefined variable in php.

I'll post a simple bit of code for you to just see if it works, then complicate it and fit the other bits around it.  I've taken this nearly all from your code so it looks familiar to you.

[code]
<?php
// Connect to the database
include 'database.php';

// Query the database and assign the results to a variable
$view = "SELECT * FROM users WHERE id = '{$_GET['id']}' LIMIT 1";
$view2 = mysql_query($view) or die("Couldn't execute $sql:\n\n" . mysql_error());
$view3 = mysql_fetch_assoc($view2) or die("Couldn't fetch the results:" . mysql_error());
$user = $view3['username'];

$admin_ids = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);

foreach ($admin_ids as $id){
  if ($view3['id'] == $id){
      $admin = "y";
  }
}

if ($admin == "y"){
  echo "{$view3['username']} is an administrator\n";
}
else {
  echo "{$view3['username']} is not an administrator\n";
}
?>
[/code]

Call this code something like testforadmin.php and make sure you pass it a value like this testforadmin.php?id=3

Post any errors that you get here.

Regards
Huggie
Link to comment
Share on other sites

OK, well I'm glad that it worked.  You could reduce the overhead even more by including a 'role' column in your database that designates whether the user is 'admin' or not...

This way you can do away with the $admin_ids array and use the value from the database to check if their admin or not.  Something like this...

[code]<?php
if ($view3['role'] == "admin"){
  echo "{$view3['username']} is an administrator\n";
}
else {
  echo "{$view3['username']} is not an administrator\n";
}
?>[/code]

Regards
Huggie
Link to comment
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.