[nycphp-talk] A SQL Query Conundrum. I Need Your Assistance...
Rolan Yang
rolan at omnistep.com
Thu Mar 2 00:12:48 EST 2006
I missed the part about "active users" in your first post, corrected
code below should read:
$result=mysql_query("select attribute_value from User_Attributes where
attribute_name in ('email','name','active') order by
user_id,attribute_name");
while (list($active)=mysql_fetch_row($result) {
list($email)=mysql_fetch_row($result);
list($name)=mysql_fetch_row($result);
if ($active=='yes') {
print "$name $email\n";
}
}
Rolan Yang wrote:
> I don't think you'll get that in a one line query, but you can loop
> through and/or dump the values into an array.
>
> quick and dirty way to print it out (assuming every id has a valid email
> & name):
>
> $result=mysql_query("select attribute_value from User_Attributes order
> by user_id,attribute_name");
> while (list($email)=mysql_fetch_row($result) {
> list($name)=mysql_fetch_row($result);
> print "$name $email\n";
> }
>
>
>
More information about the talk
mailing list