Hello genius programmers can help me to figure out my error in UNION search error in "mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean".
<?php
if(isset($_GET['search'])) {
$search_key = $_GET['search'];
$sql_search = "(SELECT lastname, firstname, 'organization_member' as type FROM org_member WHERE lastname LIKE '%" .
$search_key . "%' OR firstname LIKE '%" . $search_key ."%')
UNION
(SELECT title, 'fedetated_member' as type FROM fedetated_members WHERE title LIKE '%" .
$search_key . "%')";
$query_search = mysqli_query($CONNECTION, $sql_search);
}
?>
<div class='body_wrap'>
<div class='inner_wrap'>
<span class='text_black_big'>SEARCH RESULT FOR: <?php echo $_GET['search']; ?></span>
<table>
<?php while($row_search = mysqli_fetch_array($query_search)) { ?>
<tr>
<td><br><?php echo $row_search['organization_member'] ?><br><br><?php echo $row_search['fedetated_member'] ?><br></td>
</tr>
<?php } ?>
</table>
</div>
</div>
https://msdn.microsoft.com/en-us/library/ms180026.aspx
Combines the results of two or more queries into a single result set that includes all the rows that belong to all queries in the union. The UNION operation is different from using joins that combine columns from two tables. The following are basic rules for combining the result sets of two queries by using UNION: The number and the order of the columns must be the same in all queries. The data types must be compatible.
Your query string is incorrect so $query_search variable equal FALSE:
$query_search = mysqli_query($CONNECTION, $sql_search);
Your SELECT statements must select columns same type and the column names from the first SELECT statement are used as the column names for the results returned. You can find out more here: UNION Syntax