Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Mar 2008
    Posts
    61
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Doing functions based on result

    How would i go about doing
    Code:
    SELECT firstname FROM users WHERE username = '$_SESSION[username]'
    and if mysql result (from doing the above selection) is "jake" do this function , else this function.

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,633
    Thanks
    4
    Thanked 148 Times in 139 Posts
    you would handle that in your front end application code.

  • #3
    New Coder
    Join Date
    Mar 2008
    Posts
    61
    Thanks
    2
    Thanked 0 Times in 0 Posts
    yea. I am doing it in PHP, and i want to know how i would go about doing it in PHP.

    SELECT firstname FROM users WHERE username = '$_SESSION[username]'

    I want to get the result from that.. so if the result is bob , do this function , else do another function

  • #4
    Regular Coder
    Join Date
    Dec 2006
    Posts
    166
    Thanks
    9
    Thanked 4 Times in 4 Posts
    PHP Code:
    $sql "SELECT firstname FROM users WHERE username = '$_SESSION[username]'";
    $result mysql_query($sql);
    $row mysql_fetch_array($result);
    if (
    $row['firstname'] == 'bob')
    {
        
    someFunction();
    } else {
        
    anotherFunction();



  •  

    Posting Permissions

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