php - How to display all the columns inside a table once at least one similarity has been found between 2 database? -
- database_name1(criteria) -> table_name(tenantcriteria) , inside have following columns 
 -username
 -firsrent
 -occupation
 -age
 -tenantgender
 -income
 -history
 -address
 -tenantsmk
 -tenantpet
- database_name2(tenant) -> table_name(preference) , inside have following columns 
 
 -username
 -firsrent
 -occupation
 -age
 -tenantgender
 -income
 -history
 -address
 -tenantsmk
 -tenantpet
 3.database_name3(ad) -> each table has usernames name, hence table_name($username) , inside have following columns
 
 -adtype
 -roomtype
 -negotiable
 -price
 -include
 -title
 -address1
 -address2
 -postcode
 -city
 -province
 -image
 -description
 
 if user log in's tenant, , wants see property sell, click on rentalmatch button , button supposed check similarities between tenants preference table , go through tables in criteria database , return username criteria database have @ least on similarity tenants preference. once returns usernames want go database *(ad) tables have usernames name found before. go inside usernames table , show property that user selling.
so far have:
<?php     $conn = mysqli_connect("localhost", "root", "root");     $sql = "             select t.username             criteria.tenantcriteria t          join tenant.preference p                         on t.firstrent = p.firstrent or t.occupation = p.occupation or t.age = p.age                             or t.gender = p.gender or t.income = p.income or t.history = p.history                             or t.address = p.address or t.smoker = p.smoker or t.pet = p.pet                           p.username = $username";                          $result = mysqli_query($db,$sql) or die(mysql_error());                               ?> from here on out should do? php good? if not should be?
this show properties in html list, use <table> instead.
echo "<ul>"; while ($row = mysqli_fetch_assoc($result)) {     $owner = $row['username'];     echo "<li>owner: $owner<ul>";     $owner_query = mysqli_query("select * ad.$owner");     while ($property = mysqli_fetch_assoc($owner_query)) {         echo "<li><dl>";         foreach ($property $col => $val) {              echo "<dt>$col</dt><dd>$val</dd>";         }         echo "</dl></li>";     }     echo "</ul></li>"; } echo "</ul>";