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 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2013
    Posts
    32
    Thanks
    2
    Thanked 0 Times in 0 Posts

    check value from 2 tables and compare

    I need to check values from 2 different tables and make sure the admin_id match then do
    if (value1 = value2) {
    //do something
    }

    this is what I have so far.

    Code:
    $admin_id = $user_data['id'];
    $check_deal = "SELECT * FROM deals WHERE `admin_id` = $admin_id";
    $check_visits = 
    $req_visits = "SELECT * FROM customers WHERE `admin_id` = $admin_id AND `visits` = $check_visits";
    
    
    if ($check_visits = $req_visits) {
    
    }

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    I'm confused. Assuming that these are related, why not just do a join for what you want? If there's no matching record, then the query will return false and therefore implies that they are not equal.

    There's no information for $check_visits nor $req_visits either, so we can make no comparison between the two to suggest an alternative. Also, = is not a comparison, its an assignment in PHP.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


  •  

    Posting Permissions

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