I have 2 tables with same field sponsor. I am trying to get data from both the tables.
When i try to get data from single column it works properly for example:
$q1 = " SELECT username FROM member_master WHERE sponsor = 'user1' UNION SELECT fname FROM upgrade_master WHERE sponsor = 'user1' "; But when i add more columns in query it gives error mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\
This is my code:
<?php require("connect.php"); $q1 = "SELECT username FROM member_master WHERE sponsor='user1' UNION SELECT fname, lname FROM upgrade_master WHERE sponsor='user1'"; $e1 = mysqli_query($connection, $q1); if(mysqli_num_rows($e1)>0) { echo '<table><tr>'; while($row = mysqli_fetch_assoc($e1)) { $username = $row['username']; $fname = $row['fname']; $lname = $row['lname']; echo '<td>'. $username . '</td>'; echo '<td>'. $fname . '</td>'; echo '<td>'. $lname . '</td>'; } echo '</tr></table>'; } ?>