I'm trying to create a search function that will retrieve search results for different posters we're creating on our site. If a person is searching for lets say "dog" then it will show the posters which is related to dogs. The site is going to publish different events in the form of posters.
The code looks as following at the moment:
<?php
class Search
{
public static $con;
private $search = '';
function __construct()
{
self::$con = mysqli_connect('localhost', 'guest', 'guestpw', 'db_users');
$this->search = mysqli_real_escape_string(self::$con, $_POST['search']);
}
if(isset($_POST['submit_search']))
{
$sql = mysqli_query($con, "SELECT * FROM Event WHERE eventNamn LIKE '%" . $search);
$sql = mysqli_query($con, "SELECT * FROM Användare WHERE userName LIKE '%" . $search);
$sql = mysqli_query($con, "SELECT * FROM Poster WHERE Kategori LIKE '%" . $search);
$sql = mysqli_query($con, "SELECT * FROM EventTyp WHERE EventTyp LIKE '%" . $search);
$result = mysqli_query($sql);
}
}
What I want to happen now is to use the search word the user is searching for and then display the events that are associated with that word. All help is much appreciated! Thank you.