Reputation: 97
hello I developped a search form with php,which is working perfectly,but I would like to filter for example alphabetically,so I defined some anchors in my html document A| B | ....
In my php document,I added:
$search=$_POST['query']//query is the name of input in a form,on the same html doc
$letter=$_GET['by'];
from my sql query,
$sql=SELECT Title FROM table where Title LIKE %search%;
I added :
if(isset($letter)){
$sql .="AND Name LIKE '$letter' ";
}
My problem is that when I click for example on the link "A" it always display all entry corresponding of all titles having names beginning of letter"A".(my Table has 2 columns,Title and Name) So I would like when I do a search to filter the results(getting when I click on "A" titles for which names begin by "A" and only those returned on the result of the search)
Upvotes: 0
Views: 1029
Reputation: 212412
I hope you have a space before the AND; but you need to wildcard the LIKE
$sql .=" AND Name LIKE '$letter%' ";
Upvotes: 1