I have to tables.
The first one (members) contains my customers id|name|email|key
The second (types) contains listings customer subscribes to id|customer_id|type|active
What I would like to do is to list all members that subscribed to a type of list. I can do this with 2 sql:s, but I guess there must be a better and faster way using som kind if JOIN maby and besides I get the wrong ORDER for my customers doing my way. I want ORDER by name.
<?
$type ='555';
$sql = mysql_query(" SELECT * FROM types WHERE type='$type' && active='1' ");
while($a = mysql_fetch_array($sql))
{
$sql2 = mysql_query(" SELECT * FROM members WHERE id='{$a['customer_id']}' ");
while($b = mysql_fetch_array($sql2))
{
echo 'Name: '.$b['name'].'<br>';
}
}
?>