I have this MySQL
table containing a list of words:
desc words;
+---------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| word | varchar(255) | NO | | NULL | |
+---------+--------------+------+-----+---------+----------------+
I also have a HTML
form with three input fields where the user should enter three letters:
<form action='load.php' method='post'>
<input type='text' name='first_letter'>
<input type='text' name='second_letter'>
<input type='text' name='third_letter'>
<input type='submit' name='submit'>
</form>
Is it possible to create a MySQL
query to fetch words containing the three letters in order of apperance, in the word?
For example if we have the words
adams
damn
mad
... and the user submits the letters "a", "d", "m" it should only give the result
adams
since the first submitted letter is "a", and the second submitted letter comes after "a" and so forth (even if there is other letters in between).
Or is it easier to sort the words using PHP
? If so, how? I'm a beginner programmer.