PHP How to use LIKE in a DB query
How to use LIKE in a DB query:

Using the LIKE operator you can sort the output so it will find the results matching according to how you specify in the query.
BR />To the right of here I explain the use of LIKE by giving some examples.
You can use the wildcard '%' in your LIKE query.

 Use LIKE to extract content from a DB

How do you use LIKE querying a Database using PHP?

Now, in this post, we will look at the SQL operator 'LIKE'.
No, it's not about facebook, but it's about finding content from your database using words, or part of words, for searching, where you will get results, containing your seachphrase.

Imagine searching for '%angel%'. With LIKE you will get 'Angel', 'Angels', 'Los Angeles', 'Archangel', and so on.

If you use this; '%ing' you will search for word ending in 'ing'.
On the other hand, if you do this; 'be%' you search for words beginning with 'be'.

If you want to find all words with the phrase 'tt', you can do this; '%tt%'. Then your result will be words with 'tt' somewhere in it. Like getting, lotto, betting, setting, etc.

Notice that if your table does not contain any Lastnames that ends with the string 'sen', then you will not get any result. Either try to add some rows to the table, as seen in an ealier posting, or change the %LIKE% pattern in the SQL string, in the above codesnippet.


    $con = mysqli_connect('', 'root', 'Your_Passwords', 'dbname'); 

    if (mysqli_connect_errno()) { 
        echo 'Error connecting to DB'; 

    $SQL_String = mysqli_query(
    $con, 'SELECT * FROM contacts WHERE Lastname LIKE '%sen''); 

    while($row = mysqli_fetch_array($SQL_String))  { 
        echo $row['AutoID'] . ': ' . $row['Firstname'] . ' ' . $row['Lastname'] . ''; 
    mysqli_close ($con); ?>
Icons made by Freepik from This page is about how to find the content in a database using LIKE.