Display Join Records Using ID

wxdqz

New Member
I have and organization table that has a column name customer_type_id, and a customer_type table that has the list of available customer types for the organizations.

customer_type_id is the id of customer_type table, I use this to do joins between the two tables.

I want to display the organization info in a table like this

Name Address City State Type


Instead of the type column listing the customer_type_id as a number, I want it to read the actual type pulled from the customer_type table.

I have been trying to do this with multiple query抯 and a while loop with an embedded if statement, like this

<? $customerType = 0;

while( $result = mysql_fetch_row($query)) {

//printf("$result 1 is $result[1] \n") ;
printf("cust_typeid is $r->cust_typeid <BR>\n");
if($r->cust_typeid == $result[0]){
printf ("enter if");
$customerType = $result[1];
break;
}
} //end result while loop
?>

<td class=normal BGCOLOR="<? echo $RowColor; ?>"><? pv($customerType) ?></td>


$result is the results from the query of the customer_type table and $r are the results from the query of the organization table.
 
Back
Top