Opportunities:
Name Contact Board Ref Board Num Status "; // form the query for selecting info of each contact from the seleced accounts include("db_connect.php"); $query="SELECT o.*, c.first_name, c.last_name, p.name AS product_name, s.name AS status_name FROM opportunities o LEFT JOIN contacts c ON o.contact_id = c.id LEFT JOIN product_types p ON o.product_id = p.id LEFT JOIN status_types s ON o.status_id = s.id WHERE $field=$value ORDER BY name DESC"; $result=mysql_query($query) or die(mysql_error()); mysql_close(); // loop through all quotes and list data $i = 0; while ($row = mysql_fetch_assoc($result)) { $id = $row['id']; $name = $row['name']; $first_name = $row['first_name']; $last_name = $row['last_name']; $full_name = $first_name.' '.$last_name; $board_ref = $row['board_ref']; $board_num = $row['board_num']; $status_name = $row['status_name']; $row_color = ($i % 2) ? $color1 : $color2; echo " $name $full_name $board_ref $board_num $status_name "; $i++; } // ends table echo ""; } ?>