Mysql Query Help needed
| From: | Chris Kay | Date: | Thu, 16 May 2002 10:04:37 +0000 |
| Subject: | Mysql Query Help needed | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-97889@lists.php.net to get a copy of this message | ||
I have a query
"select cust_fnn, cust_name, agroup_access.group_access_cust from cust,
agroup_access where
agroup_access.group_access_group='$id' &&
cust.cust_fnn!=agroup_access.group_access_cust order by cust.cust_name"
The 2 tables are as follows
agroup_access
agroup_access_id agroup_access_group
agroup_access_cust
1 9
1610005847
2 9
0265478986
3 9
1610010254
Cust
cst_id cust_name cust_fnn (ect....)
1 xxx 1610005847
2 xxxxx 0265478986
And so on.... 200+ records
What I am trying to do is pull all records from cust where cust_fnn !=
agroup_access_cust && agroup_access_group=9..
What I am getting is all cust_fnn records but 3 of each and only 2 in
the case of it matching the
agroup_access_cust..
Can anyone see what I may have dome wrong..
I am trying to display them in a drop down box, below is the function
for the drop down box and the line to call the function..
combo5("fnn","select cust_fnn, cust_name,
agroup_access.group_access_cust from cust, agroup_access where
agroup_access.group_access_group='$id' &&
cust.cust_fnn!=agroup_access.group_access_cust order by
cust.cust_name","");
function combo5($name, $query, $sel) {
$dbq=mysql_query($query);
$html="<select name=\"$name\" class=\"longdd\">\n";
while( $data = mysql_fetch_array($dbq) ) {
if($data[cust_fnn]==$sel)
$html.="<option value=$data[cust_fnn]
selected>$data[cust_name] : $data[cust_fnn]</option>\n";
else
$html.="<option
value=$data[cust_fnn]>$data[cust_name]: $data[cust_fnn]</option>\n";
}
$html.="</select>\n";
return $html;
}
Hope someone can help...
-------
Chris Kay, Eleet Internet Services
chris@eleet.com.au
-------