PDA

View Full Version : "Combo with Templates and Ajax" - Shows me all entries of database, not just typed in



chrisgd
20 Sep 2012, 1:04 AM
Hello,


I have an understanding problem with the example "Combo with Templates and Ajax".
http://dev.sencha.com/deploy/ext-4.0.0/examples/form/forum-search.html



I created my own mysql-database and the app works, except that it shows me all entries of the database, not just the ones with the characters I typed in.


Do I need a special database structure or indexes for some columns?


Thanks for a little hint.


Chris

Lunti
20 Sep 2012, 5:08 AM
You have to filter in your backend. The SQL statement should have a WHERE clause with the given query.


$query = $_GET['query'];
$sqlStatement="SELECT * from myTable WHERE description LIKE '%".$query."%';";

chrisgd
20 Sep 2012, 8:07 AM
Thanks for your reply. Now I get the right results! :) I made some experiments with WHERE and LIKE, but it´s my first steps with databases and the code '%".$query."%' was the thing I was looking for. You saved my sleep. ;)

Lunti
20 Sep 2012, 10:35 AM
You're welcome:D

The % is a wildcard in SQL, used in combination with "LIKE".