This question already has an answer here:
I want to join two diffrent database tables when i compared with common field (ID).The following code i was wriiten on my website but it shows an error
My code :
$conn = mysqli_connect("localhost", "username1", "password1", "databse1");
$conn1 = mysqli_connect("localhost", "username2", "password2", "database2");
$result = '';
$query = "SELECT * FROM database1.table1,database2.table1 where
database1.table1.id=database2.table1.id ";
$sql = mysqli_query($conn,$query);
$result .='
<table class="table table-bordered">
<tr>
<th width="20%">ID</th>
<th width="10%">Qty</th>
</tr>';
if(mysqli_num_rows($sql) > 0)
{
while($row = mysqli_fetch_array($sql))
{
$result .='
<tr>
<td>'.$row["id"].'</td>
<td>'.$row["qty"].'</td>
</tr>';
}
}
else
{
$result .='
<tr>
<td colspan="5">No Item Found</td>
</tr>';
}
$result .='</table>';
echo $result;
Error Messages :
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in
Please assist and help me...
</div>