0

Hi,

I have a database table structure that works as follows:

search_id: (auto int)
group_id: (unique to group)
field_name:
field_value:

so some entries in my db would look like this:

    search_id       group_id       field_name      field_value
    1                123456            fname             John
    2                123456            lname              Doe
    3                123456            email     jdoe@abc.com
    4                789012            fname             Jane
    5                789012            lname              Doe
    6                789012            email     jdoe@def.com

Now my current search process works as follows;
user searches for value- first query is just a contains on the field_value
forecah match - i return the group_id

my second query is a simple select * from search where group_id = 123456
and that is how i display all of the information i have about that particular group.

My question is- can anyone think of a better way to have dynamic content- (like my field_name : field_value) setup
and it be easier to query?
What is the proper way to do it? Im a self taught programmer- and I just came up with this on my own.

Any help or advice would be greatly appreciated.

Thanks,

2
Contributors
1
Reply
3
Views
5 Years
Discussion Span
Last Post by rotten69
0

If you're trying to optimise the search results and make them quicker, you need to build an index on an attribute. You can search through Id's or names in the table you've got by passing an Id. Let's say that you're getting the value of group_id and storing it in a variable called as shown below:

$some_variable= $_GET['group_id'];

"Select search_id, field_value, field_name from TABLE_NAME where group_id = $some_variable" ; 

If you're trying to achieve something in particular, just let us know so we can help you.

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.