Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 2 of 2 FirstFirst 1 2
Results 11 to 15 of 15
  1. #11
    Senior Member raspberryh's Avatar
    Join Date
    Aug 2004
    Location
    Erie, PA
    Posts
    882
    Member #
    7208
    Liked
    1 times
    Hmm, well I would think you could just do something like...
    PHP Code:
    $result mysql_query("select * from users order by name"); // grab all the users

    // go through each user
    while($user mysql_fetch_array($result)){

      
    // display form for each user where you can change their user level
      
    echo "<form action='update_userlevel.php'>";

      
    // need to send their userid for when you update this field for this user
      
    echo "<input type='hidden' name='userid' value='".$user['id']."'>";

      
    // select box to select their level
      
    echo "<select name='userlevel'>";
      echo 
    "<option value='1'>Level 1</option>";
      echo 
    "<option value='2'>Level 2</option>";
      echo 
    "</select>";
      echo 
    "</form>";

    ... And then in update_userlevel.php...
    PHP Code:
    mysql_query("update users set userlevel='".$_REQUEST['userlevel']."' where id='".$_REQUEST['userid']'"; 
    ...Now, I'm not totally sure of the syntax and everything (and plus, I'm sure your tables/fields are named differently) but this should give the general idea...
    choosy developers choose gif!
    website | paintings | blog

  2.  

  3. #12
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    You missed a period in your code raspberryh, which I corrected just incase the o/p does not notice it.

    PHP Code:
    mysql_query("update users set userlevel='".$_REQUEST['userlevel']."' where id='".$_REQUEST['userid'].'"; 
    Also, use the appropiate global array ($_POST or $_GET). This is determined by the form method tag. If your form's method is get, your code will look like
    PHP Code:
    mysql_query("update users set userlevel='".$_GET['userlevel']."' where id='".$_GET['userid'].'"; 
    If it is post it will look like
    PHP Code:
    mysql_query("update users set userlevel='".$_POST['userlevel']."' where id='".$_POST['userid'].'"; 
    Here is a useful checklist of PHP security issues explaining why and how to avoid them.

  4. #13
    Junior Member
    Join Date
    Nov 2006
    Posts
    9
    Member #
    14398
    ok, so I simply put the following line of code in a file called user_level.php?

    mysql_query("update users set userlevel='".$_REQUEST['userlevel']."' where id='".$_REQUEST['userid'].'";

    What about the other code. I assume it goes in a file all by itself and the name of that file doesn't matter?
    Thanks for your help guys!
    Buster

  5. #14
    Senior Member raspberryh's Avatar
    Join Date
    Aug 2004
    Location
    Erie, PA
    Posts
    882
    Member #
    7208
    Liked
    1 times
    Quote Originally Posted by bfsog
    You missed a period in your code raspberryh, which I corrected just incase the o/p does not notice it.
    That's why I said that I wasn't totally sure of the syntax. I was just trying to give a GENERAL idea.

    Quote Originally Posted by bfsog
    use the appropiate global array ($_POST or $_GET)
    AGAIN, just trying to give the GENERAL IDEA.
    choosy developers choose gif!
    website | paintings | blog

  6. #15
    Senior Member raspberryh's Avatar
    Join Date
    Aug 2004
    Location
    Erie, PA
    Posts
    882
    Member #
    7208
    Liked
    1 times
    Quote Originally Posted by w4designs
    ok, so I simply put the following line of code in a file called user_level.php?

    mysql_query("update users set userlevel='".$_REQUEST['userlevel']."' where id='".$_REQUEST['userid'].'";
    Yeah, but you'll have to change it a little depending on the table names in YOUR database... Plus, you'll have to add a column to your users table for user level. Also, you need the mysql_connect stuff, etc.

    Quote Originally Posted by w4designs
    What about the other code. I assume it goes in a file all by itself and the name of that file doesn't matter?
    The other code should just go in the file where you want to list the stuff out. It doesn't really matter what it's named.
    choosy developers choose gif!
    website | paintings | blog


Page 2 of 2 FirstFirst 1 2

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 08:31 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com