Hi everyone.
I am having some sort of PHP / MySql Brain Fart. Any help would be greatly appreciated. Here’s what I am trying to do:
I am using the Profile Module and I a want to create a “stats page”.
I want to pull UID that contains two specific values. The “Profile_Values” table contains three rows. FID, UID, VALUE.
FID is the field
UID is the userid
Value..well, that’s the value of the FID.
In the database, I have:
FID UID VALUE
2 5 2002
3 5 Bill
4 5 Johnson
I want to pull users (UID) that have selected “2002” and that the last name is “Johnson”.
For this example, I am not interested in pulling the first name (FID 3).
Here is am looping the results to get the UID’s for 2002:
$query="SELECT * FROM profile_values WHERE value = '2002'";
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
$value=mysql_result($result,$i,"uid");
echo "$value <br>";
$i++;
}
This generates the a list UID’s that contain 2002 as a value.
From this list, I need to see who (which UID) has the last name (Value = ‘ Johnson’) Johnson.
So I tried this:
$own3d = db_result(db_query("SELECT COUNT(*) FROM {profile_values} WHERE uid='$value' AND value = 'Johnson'"));
print "$own3d";
But pulls nothing.
Any help would be greatly appreciated.