The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.18 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Database search filter
#31
See if you like this:

http://pastebin.com/cVQxNGW4

It replaces more than 150 lines with less than 30 lines by using a dynamically created SQL query instead of n individual separate queries...
  Reply
#32
Thanks guys, I will have a look at it all Smile
  Reply
#33
I have been trying several things today, but I just don't seem to be getting it quite right yet.

What would I have to change in this code so that if checkbox "Projects" is checked in combination with for instance "Large animals, something and children", that it only displays projects that involve large animals, something and children?

In the database users either have a 1 or a 0 in the project or volunteer column (which is set during their registration).
  Reply
#34
It's not clear what you're referring to. Yesterday I did a pretty major re-write on the previous versions that were suggested. Have you tried that or are you working on a previous version? What does your code look like now?

Are you saying "how would I combine with boolean AND instead of boolean OR if I have the 'Projects' checkbox checked"?

What is the connection with volunteer?

  Reply
#35
I am still trying to wrap my head around what you did there. I have put your code into my page ( http://pastebin.com/R9egDbtg ) but its not working. I get a blank page. So I'm still working on that.

Meanwhile I also went back to the other version I had and tried to implement the stuff I mentioned above.
I'm sorry if I was unclear. Let me try to clarify...

I have two registration forms, one for Volunteers and one for Projects. The Volunteer form automatically adds a 1 to the volunteer column and a 0 to the project column (and vice versa for the Project form). This makes those users distinguishable from each other.

I want to be able to have users (volunteers or projects) to do a search for either Volunteers that have shown an interest in small animals, large animals, etc. or Projects that involve small animals, large animals, etc.

I can filter for volunteers or projects with this code now: http://pastebin.com/DkXsDwRV
but it shows everyone when I check more boxes (not just volunteers with certain interests)
  Reply
#36
Does anyone have any ideas how to tackle the latter?
  Reply
#37
I noticed that the first 3 (project, volunteer, and maybe small animals) don't have the if !in_array statement in them. I wonder if that's where your problem is. If you can't get this sorted, let me know and I may have you send me more code and a sql dump in a zip file. You've been working on this a while and I want to help you get it sorted.
  Reply
#38
Hey Mudmin,

thank you for your response. I have added the if !in_array stuff to those lines, but that is not the problem.

I think I need to alter the query somehow into something like:
Code:
SELECT * FROM users WHERE project ='1' AND small_animals LIKE '{3bc1fe685386cc4c3ab89a3f76566d8931e181ad17f08aed9ad73b30bf28114d}" . $name . "{3bc1fe685386cc4c3ab89a3f76566d8931e181ad17f08aed9ad73b30bf28114d}'
so that when the project box AND the small animals box are checked I only get the results from users that have the project status and the small animals interest...and not any volunteers that have also indicated an interest in small animals.

I just dont seem to get how and where I need to add that code. So if you have any ideas on that, that would be awesome Smile
  Reply
#39
I have something similar for search terms in my costco search engine. Are you talking about something like this?

There is a search box named 'input'

Code:
$query = Input::get('input');
Code:
$query = htmlspecialchars($query);
Code:
$costcoQ = $db->query("SELECT * FROM costco WHERE descrip LIKE '{3bc1fe685386cc4c3ab89a3f76566d8931e181ad17f08aed9ad73b30bf28114d}$query{3bc1fe685386cc4c3ab89a3f76566d8931e181ad17f08aed9ad73b30bf28114d}' OR item_num
Code:
LIKE '{3bc1fe685386cc4c3ab89a3f76566d8931e181ad17f08aed9ad73b30bf28114d}$query{3bc1fe685386cc4c3ab89a3f76566d8931e181ad17f08aed9ad73b30bf28114d}' OR brand LIKE '{3bc1fe685386cc4c3ab89a3f76566d8931e181ad17f08aed9ad73b30bf28114d}$query{3bc1fe685386cc4c3ab89a3f76566d8931e181ad17f08aed9ad73b30bf28114d}'OR size LIKE '{3bc1fe685386cc4c3ab89a3f76566d8931e181ad17f08aed9ad73b30bf28114d}$query{3bc1fe685386cc4c3ab89a3f76566d8931e181ad17f08aed9ad73b30bf28114d}'");
Code:
$costco = $costcoQ->results();
Code:
$count = $costcoQ->count();
  Reply
#40
I should have worded that differently, sorry. I am not working with search terms but with checkboxes.
My search page looks like this (some fictional choices):

[] Projects
[] Volunteers
[] Small animals
[] Large animals
[] Animal habitat
[] Environment
[] Habitat
[] Something
[] Children
[] Elderly
[] Disabled
[] Homeless

See here: http://pastebin.com/VMx1Z65r

Now, what I need is when someone checks the Volunteers box (and therefore selecting only users that have indicated that they are a volunteer and not a project...which in the database is set as 1 or 0) and also checks some other boxes (which are simply given the same name in the database), that the results only give me volunteers that have indicated the corresponding interests in their profile.

So checking the volunteer, habitat, elderly and disabled box will give me a result of volunteers that have set habitat, elderly and disabled as their interests in their profile.

If someone check the boxes project, small animals, environment....it only shows users that are set as a project with
the corresponding subjects (small animals and environment).

If someone checks the projects, volunteers, large animals and elderly boxes it will show all the volunteers and projects that have those subjects in their profile.

Does that make sense?
  Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)