0

$tag = $_GET[tag];
$search = mysql_query("SELECT * FROM `threads` WHERE FIND_IN_SET('$tag', `tag`) = '$tag'");

why is this returning all of the rows in the table they all do not have the same tags none of them have the same tags as each other yet
the column name is tag.
the search term is $tag in the url (hence the get)
please i do not understanddddddddddd help!?

and then i tried taking the = '$tag' part out and well.... its not working... at all. even tho the tag matches one of the rows tag feild.. it comes up NOTHING.

4
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by drjohn
0

The FIND_IN_SET function is used to search a list of strings for a specific string. I don't think you need to do this. Your query should look something like this I think:

$tag = $_GET[tag];
// NEED TO PERFORM SOME DATA CHECKS HERE...
$search = mysql_query("SELECT * FROM threads WHERE tag = '$tag'");
0

yeah im actually using like %tag% but i dont know any other way to do it. which really bothers me its not too precise. like if i search for e, everything with an e in it comes up not things that are specifically tagged e.

0
$tag = $_GET[tag];
$search = mysql_query("SELECT * FROM `threads` WHERE FIND_IN_SET('$tag', `tag`) >0");
0

does the tag field contain one tag eg blue
or do you have multiple tags in it eg blue, sky, clouds

If it's the second one, start by redesigning your database! Because the second means you have to rebuild it and have a threads table and a tagged table
thread---<tagged
where tagged contains thread id and the actual tag.

If it was the second one, your database is not even in first normal form. And hence you are doomed.

Edited by drjohn: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.