Page 1 of 1

Search Across Categories?

Posted: 2015-06-03 00:08
by 99er510
I'm not very familiar with databases, so please bear with me if I'm not using the correct terminology.

I'm designing a database of equipment and software for a retro computer (TI-99/4A if you're interested... :D ti99db.org). It's coming along nicely - when you visit index.php, you get the link buttons for the categories that I've created: cartridges, hardware, software (floppy/cassette), and literature. Is there any way to provide a way to search through all of those categories? For example, some companies made products that fell into each category and if you searched for such a company, I'd want it to return with the items they made regardless of category. Or, if a user searched for 'spreadsheet' I would want it to return with results for spreadsheet programs in both the cartridge and software categories.

Is there a better way to do this? Am I looking at it wrong? Would the key be to use parent/children records? I did create a category for companies so that when you open one of those records, the products that they made are listed at the bottom. However, while that's a nice feature, I don't think that it's very obvious to users, and I don't want to create parent/child links for all of the duplicate fields in each category. I also considered using only one category for all items, but there are some fields that are particular only to each category, and I didn't know if there was a way to make some fields only show if a particular choice has already been selected (sort of like a sub-field).

Sorry if I blabbered on there- writing this got me thinking about possible options. I'm also wondering if the key might have to do with filtering...


Thanks,
Rich
99er.net

Re: Search Across Categories?

Posted: 2015-06-04 10:28
by a.gneady
You need to create a custom script for this that would display a search box and when search is submitted, would perform a search in each table then combine and list the search results. I'll try to write an example code for this soon.

Re: Search Across Categories?

Posted: 2015-06-08 03:05
by TheNoLifer
I would find that 'global' search particularly useful too. Would be extremely grateful for some example code for this.

Re: Search Across Categories? (Tables?)

Posted: 2015-06-19 03:38
by 99er510
Yes- thank you! That example code would be great. I eventually hope to be able to pull records from all tables depending on the user, so learning how to do something like this would be really helpful.

Thanks,
Rich

Re: Search Across Categories?

Posted: 2018-02-14 17:51
by H TARIK
Dear Ahmad and php pros.
I am new on appgini and i am not a php coder. I want to do some application for my business.
I really want to do search box for all tables in my application.
Any suggestion on this issue or if you done a script for this?
Thank you very much.

Re: Search Across Categories?

Posted: 2018-03-07 13:04
by a.gneady
Oh! This thread has been open for quite some time now :) And I didn't get to write that tutorial ... so here is a gist I created on github to perform global-search: https://gist.github.com/bigprof/1dc6bc2 ... c48c2a4cc7

And here is some sample output:

Image

Re: Search Across Categories?

Posted: 2018-03-08 07:33
by salemsaleem76
Very Nice Ahmad but, why we could not have table header at the top of the page, If the data I am looking at is too long and in many tables I need to scroll too many times to find that.

Re: Search Across Categories?

Posted: 2018-03-08 16:13
by H TARIK
Thank you Ahmad.

Re: Search Across Categories?

Posted: 2018-03-08 17:51
by Panadu
I have Problems with the global search.
I implemented the code and i found the Search-Button. If i search for anything, i got a error Message from SQL:

Unknown column 'house_viewport.' in 'field list'

SQL-Anfrage:
SELECT `house_viewport`.`` as 'PRIMARY_KEY_VALUE', `house_viewport`.`ID_ANZEIGE_OPTION` as 'ID_ANZEIGE_OPTION', `house_viewport`.`ANZEIGE_OPTION` as 'ANZEIGE_OPTION', `house_viewport`.`ANZEIGE_OPTION_BESCHREIBUNG` as 'ANZEIGE_OPTION_BESCHREIBUNG', `house_viewport`.`ANZEIGE_SORTIERUNG` as 'ANZEIGE_SORTIERUNG' FROM `house_viewport` WHERE 1=1 AND CONCAT_WS('||', `house_viewport`.`ID_ANZEIGE_OPTION`, `house_viewport`.`ANZEIGE_OPTION`, `house_viewport`.`ANZEIGE_OPTION_BESCHREIBUNG`, `house_viewport`.`ANZEIGE_SORTIERUNG`) LIKE '%1111%'

The above info is displayed because you are currently signed in as the super admin. Other users won't see this.

Can You help? All is correct in use, but the global search produces a error.

Thank You

Re: Search Across Categories?

Posted: 2018-03-08 18:08
by Jay Webb
Great add on, worked for me, I have 4 large tables. Thanks a.gneady.

Re: Search Across Categories?

Posted: 2018-03-09 09:25
by Panadu
SOLVED - Appgini dont created a column in my table. I added all manually, now its working.

Bye

Re: Search Across Categories?

Posted: 2018-03-31 03:02
by David Soul
a.gneady wrote:
2018-03-07 13:04
Oh! This thread has been open for quite some time now :) And I didn't get to write that tutorial ... so here is a gist I created on github to perform global-search: https://gist.github.com/bigprof/1dc6bc2 ... c48c2a4cc7

And here is some sample output:

Image
I want to assign the link to a specific group rather than default to last group listed.
I tried appending this:
'table_group' => 'group-name’
To the code supplied for hooks/links-home.php but it “breaks” and the home page no longer displays any of the groups!

I have a similar problem if I try to add a stand-alone menu item for the search.

Is there a known reason why the code should not accept this table_group assignment?

Re: Search Across Categories?

Posted: 2018-03-31 16:12
by David Soul
I found code here that lets me put button on menu bar which allows functionality to call global search but like advice on using ‘table_group’ in array in “hooks/links-home.php’
Code from AppGini advice re menu bar “button”:
You can add links to the navigation menu by adding some JavaScript code to hooks/footer-extras.php
For example:
<script>$j(function(){ $j('nav .navbar-collapse').append( '<ul class="nav navbar-nav">' + '<a href="link-url" class="btn btn-default navbar-btn">Test Link</a>' + '</ul>' ); })</script>

Re: Search Across Categories?

Posted: 2018-07-17 09:34
by Melroy
The global search page displays all fields for each record. This is not a problem for my groups who have full ownership rights but there is one group I restrict from seeing the detail view. Is there a way to select the fields to hide for all groups or better still, just for the one group I mentioned.

(I am using ver: 5.71)

Re: Search Across Categories?

Posted: 2018-07-21 08:00
by pbottcher
Hi,

what do you mean by restricting to see the datail view. The data is catched from the tables. Do you want to exclude tables from the search?

Re: Search Across Categories?

Posted: 2018-08-08 10:06
by Melroy
Hi pböttcher,

My apologies for not responding to your reply earlier.

I guess what I am trying to say is that I want to set up the global search to search across all tables but only in those fields displayed in my table view and not the detail view which might contain private information.

Re: Search Across Categories?

Posted: 2018-08-08 12:52
by a.gneady
Hmm ... one possible way to do this is to insert some code directly after line 29 to filter out the private fields from $results array. So, you could add a check on the user group and if it matches some specific group, loop through the $results array and unset the elements representing the private fields.

Re: Search Across Categories?

Posted: 2018-08-08 13:16
by Melroy
I can probably make life a little simpler by restricting all groups from seeing the detail view fields. The priority for me is for users to search the 'title' and 'description' fields in the table view. A pdf or image link, provided in the table view would then take them to a relevant document/image. That presumably means I would only need to filter out the fields in the details view? My problem is (as always) that I am not proficient in coding so will need help on that.

Re: Search Across Categories?

Posted: 2023-11-03 22:36
by xbox2007
thanks a lot Mr Ahemd its very nice
but i would like ask if i can choice single table only ?
also
how if i want search on two or three table not all tables

thanks a lot

Re: Search Across Categories?

Posted: 2023-11-07 16:52
by a.gneady
xbox2007 wrote:
2023-11-03 22:36
thanks a lot Mr Ahemd its very nice
but i would like ask if i can choice single table only ?
also
how if i want search on two or three table not all tables

thanks a lot
One way to do this is to change line 89 of the script from:

Code: Select all

$tables = getTableList();
to:

Code: Select all

$tables = [
    'table1' => [], 
    'table2' => [],
    'table3' => [],
];
The above would limit search to table1, table2 and table3. Of course, replace those by the actual table names in your case.