Question: I'm making my search function but I don't know how to select only rows that contain the search terms. The idea would be to select only rows with the string $search from the table `lines` in the column "Text". How could I do it? Thanks

Answer: 
```
$query = "SELECT * FROM lines WHERE Text LIKE '%".$search."%'";

```

Using mysql's LIKE combined with wildcards(%) should do the trick.
```
select * from lines where Text = $search

```

or use

```
select * from lines where Text like '%$search%' 

```

if you want to search for a value that includes $search but doesn't exactly match it.

EDIT
----

If $search only includes part of a value in Text but doesn't match the order of the words, I.E Text's value = "pizza in paris" and `$search = "pizza paris"`, then you can split $search into separate strings and run a search with an `and` clause.

```
select * from lines where Text like '%$search1%' and Text like '%$search2%'

```

where `$search1` is the first word and `$search2` is the second word.