SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2008
    Posts
    184
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help with ELSE statement

    Hi, I am creating and IF/ELSE statement. I want the IF statement to ask for one specific condition to be met, and if that condition is not met, there will be an ELSE statement run instead. My only problem is how do I get this query to run the ELSE statement once. At the moment, using my query below it will run the ELSE statement for each field in the database with contact_id=$mye_id as specified in my query here but where $contribution_type_id does not equal '8', as in the part of my query lower down. How can I change this so the ELSE statement only runs the once?

    Thanks
    Russ

    Code:
        $query = "SELECT contact_id, contribution_type_id FROM civicrm_contribution WHERE contact_id=$mye_id";
       
    	$result = mysql_query($query) or die('Error, list committee members failed. ' . mysql_error());
    	
    	while(list($contact_id, $contribution_type_id) = mysql_fetch_array($result))
    	{
    
    	if ($contact_id === $mye_id AND $contribution_type_id === '8')
    		
    	{
    echo 'First statement';
    }
    else {
    echo 'Second statement';
    }
    }

  2. #2
    SitePoint Addict
    Join Date
    Oct 2008
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    SitePoint Guru
    Join Date
    Sep 2004
    Posts
    613
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol, yep, that's your answer.


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
  •