Reputation: 57312
I want to search the computer from this table and when i have stored this in database so now can find the string and pass to the query so it this string present in database then show result
i am doing
i am getting the value form the url my url looks like localhost\demo\article.php?filter=computer
$_GET['filter']
my database is
id | name |tag
1 |java |a:2:{i:0;s:8:"Computer";i:1;s:4:"Code";
2 |dbms |a:2:{i:0;s:8:"Computer";i:1;s:4:"dbms";
3 |c |a:2:{i:0;s:8:"elect";i:1;s:4:"Code";
now i am want to fetch all the row where the computer is present or code
for that i am using the query
$query1 = "SELECT * FROM $tableName WHERE tag='%".$_GET['filter']."%' ";
but its not showing the row having the computer or code..
its like the stackoverflow tag filtration
Upvotes: 0
Views: 704
Reputation: 5169
Solving your problem is by replacing =
with like
so your query should be
$query1 = "SELECT * FROM $tableName WHERE tag like '%".$_GET['filter']."%' ";
a better way of doing this, is to create extra two tables. One will contain your tags (optional) and the other will contain tagging information.
This article will help you so much
Upvotes: 5
Reputation: 43158
Normalize your database and you will no longer need to turn a nail with a screwdriver.
Upvotes: 4