SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2002
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySQL Query Question

    I'm just learning MySQL/PHP programming here so please bare with me hehe.

    I'm coding my website right now, with PHP/MySQL and am working on a login system.
    I have already made a page that inserts user data(a registartion page) into the database. So I can use the INSERT into query fine.

    I can also successfully check a username/password entered into a form against that of the database using the SELECT * FROM ...WHERE ...

    Now I want to do something, to the effect of an admin being able to allow or disallow registartions, by either inserting a 1 or a 0(yes and no on the form) into the database under a colum like "admin approve".

    So for this, I'm thinking that I'll have to use a query that takes the data from the databse(either the 0, or the 1 in this case) and puts it into a variable for PHP to use. If this is the right idea to what I have to do, what query, or set of querys/php statements can take data from the database and turn it into a variable??

    Also, if this is not the right way to do it, could someone please explain to me how to do this? Thanks

  2. #2
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Lets say you have a column in your table
    approved TINYINT UNSIGNED NOT NULL
    PHP Code:

    $sql 
    "SELECT * FROM tableName WHERE {your condition}";
    $result mysql_query($sql);
    $row mysql_fetch_array($result);

    // now $row['approved'] will be either 1 or 0
    // 1 evalates to true and 0 evaluates to false

    if ($row['approved']) 
    {
       
    // the user has been approved

    else 
    {
       
    // the user has not been approved



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •