Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8206093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:32:39+00:00 2026-06-07T08:32:39+00:00

I am looking for the most efficient method to do the following… I have

  • 0

I am looking for the most efficient method to do the following…

I have a table with three fields: id, eventid and movetype – and I have the following code to query the database for all entries with a matching eventid :

$get_results = mysql_query("SELECT * FROM table WHERE eventid='$eventid'");
while($row = mysql_fetch_array($get_results)){
    // store results in array
    $move_type_array = explode(" ", $row['movetype']);
}

Please note: movetype can only be three values: Internal, Outgoing, Incoming

Using a set of dummy data, var_dump($move_type_array) could output:

array(1) { [0]=> string(8) "Internal" } array(1) { [0]=> string(8) "Internal" }

Another example of an output would be:

array(1) { [0]=> string(8) "Internal" } array(1) { [0]=> string(8) "Incoming" } array(1) { [0]=> string(8) "Outgoing" }

I then need to check the output to see if the following conditions are met:

  1. Does the array contain Internal twice?
  2. If the array only contains Internal once, then does the array also contain Incoming and Outgoing?

If either of the conditions are met then a message should be displayed telling them which condition has been met, otherwise a message should tell them that the conditions have not been met.

I have tried using a number of PHP functions such as in_array(), and also tried storing the data in a string and using preg_match() however I was unsuccessful in both methods.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T08:32:42+00:00Added an answer on June 7, 2026 at 8:32 am

    Try this:

    $result = mysql_query("
        SELECT SUM(IF(movetype = 'Internal', 1, 0)) AS internal, 
               SUM(IF(movetype = 'Outgoing', 1, 0)) AS outgoing, 
               SUM(IF(movetype = 'Incoming', 1, 0)) AS incoming
        FROM table
        WHERE eventid = $eventid
        GROUP BY eventid
    ");
    $count = mysql_fetch_array($result);
    
    if ($count['internal'] >= 2 || ($count['internal'] == 1 
            && $count['outgoing'] >= 1 
            && $count['incoming'] >= 1)) {
        echo 'Yes';
    } else {
        echo 'No';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for the most efficient Java method that would allow me to 'delete
I have a bipartite graph and I'm looking for the most efficient iterative way
I'm looking for the most efficient method of flipping the sign on all four
I have a simple CMS running PHP/MySQL and I'm looking for the most efficient
ello, I am looking for the most efficient way to do the following: Take
I am looking for a url encoding method that is most efficient in terms
I am looking for a most efficient way to re-use widgets with different selectors...
I am looking for the most efficient way to update a number of rows
I'm looking for the most succinct solution to the following problem in JavaScript: I
What is the most efficient method of showing my data in descending order? public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.