473,608 Members | 1,809 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Comparing Single Value to Multiple Values in Single Statement??

jenkinsloveschicken
56 New Member
Is it possible to compare a single value to many in a single statement? Here is what I am attempting to do:

1. Users lands on page and via a cookie check function they are identified.
2. A query is sent to the headcount table to determine their Skill Type which also serves as the security level access identfier in this case.
3. Send the Skill Type to a function that will determine what table of reporting links they are authorized to view.

At this point I have a problem. I have basically two groups of skill sets, and two sets of reports, one for each level. There are three skill types for each group. Can I compare each set as a group(array) without having to write individual ElseIF or CASE statements?

For example, set one would be comprised of:
Skill Type
--------------
Director
Operations
Support

In the receiving function can I compare the Skill Type passed from the original page to a group of values with the same result? Kind of like an IN statement in SQL if that makes this more clear.

I hope that gives a good explanation of what I am trying to accomplish. I am attempting to avoid unneccessary code duplication if possible.

Thanks in advance!

-Jenkins
Nov 11 '07 #1
1 2336
Atli
5,058 Recognized Expert Expert
Hi Jenkins.

I'm not sure I entirely got the point, but I'll still try :)

Consider this code:
Expand|Select|Wrap|Line Numbers
  1. $first = array("John", "Mark", "Bob");
  2. $second = array("Jenkins", "Bob", "Mary");
  3.  
  4. foreach($first as $_v1) {
  5.   foreach($second as $_v2) {
  6.     if($_v1 == $_v2) {
  7.       echo "We got a match: {$_v1}";
  8.       break;
  9.     }
  10.   }
  11. }
  12.  
Which would math "Bob" and then stop.

Is this what you are looking for?
Nov 11 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1558
by: Ian N | last post by:
Hi, i was wondering if anyone would be able to help me with a problem i'm having, I currently have two tables, in a database, one is Called products, and one is called groupproducts, their are multiple groups which can be added to or removed from. I want to creat a screen which lists all of the products and then places a tick in a tick box if that products in the specified group. >From this i'd submit it to another page which update...
3
16325
by: JB | last post by:
To anyone that is able to help.... What I am trying to do is this. I have two tables (Orders, and OrderDetails), and my question is on the order details. I would like to set up a stored procedure that essentially inserts in the orders table the mail order, and then insert multiple orderdetails within the same transaction. I also need to do this via SQL 2000. Right now i have "x" amount of variables for all columns in my orders tables,...
41
3930
by: Odd-R. | last post by:
I have to lists, A and B, that may, or may not be equal. If they are not identical, I want the output to be three new lists, X,Y and Z where X has all the elements that are in A, but not in B, and Y contains all the elements that are B but not in A. Z will then have the elements that are in both A and B. One way of doing this is of course to iterate throug the lists and compare each of the element, but is there a more efficient way? ...
3
3096
by: Jason | last post by:
I have several tables with quite a few fields and I'm getting errors when trying to insert records with single quotes in the data like: name = John O'Henry or a city name of O'Fallen So I went ahead and added a replace to replace the ' with " but now other fields are having the same problem and there are multiple fields involved. This data gets into having a lot of symbols used, etc. So rather than go through and replace these quotes...
0
2213
by: rayone | last post by:
Hi folks. I need advice. 2 options, which do you think is the better option to display/retrieve/report on the data. Keep in mind reporting (Crystal), SQL Performance, VB Code, usability, architecture. Case 1: On a web page I would like to render a dropdown list
19
2638
by: Dennis | last post by:
I have a public variable in a class of type color declared as follows: public mycolor as color = color.Empty I want to check to see if the user has specified a color like; if mycolor = Color.Empty then..... or if mycolor is Color.Empty then .......
5
3796
by: Kermit Piper | last post by:
Hello, I am comparing two date values, one from a database and one that has been converted from a hard-coded string into an actual Date type. So far so good. The problem I'm having is that one of the values comes from the database, and for existing values it works fine, but if the date doesn't exist (which will always be the condition when the user first enters into the form) I am adding logic to my javascript like: if (dbDate <...
27
3847
by: Thomas Kowalski | last post by:
Hi everyone, To determine equality of two doubles a and b the following is often done: bool isEqual ( double a, double b ) { return ( fabs (a-b) < THRESHOLD ); } But this a approach usually fails if comparing doubles of different magnitude since it's hard or not possible to find a suitable threshold
5
1879
by: SneakyElf | last post by:
I need to write a function where the third parameter points to an address whose dereferenced value equals one of the array element's value, then the the function returns the index of the first matching array element. Otherwise -1 is returned. Here's what I have but I am going obviously wrong somewhere: #include <iostream> using namespace std; // This function compares values
0
8069
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8503
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8488
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6017
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3972
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4036
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2479
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1339
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.