The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$archive_pages - Line: 2 - File: printthread.php(287) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/printthread.php(287) : eval()'d code 2 errorHandler->error
/printthread.php 287 eval
/printthread.php 117 printthread_multipage



UserSpice
Database search filter - Printable Version

+- UserSpice (https://userspice.com/forums)
+-- Forum: Miscellaneous (https://userspice.com/forums/forumdisplay.php?fid=28)
+--- Forum: Modifications and Hackery (https://userspice.com/forums/forumdisplay.php?fid=29)
+--- Thread: Database search filter (/showthread.php?tid=424)

Pages: 1 2 3 4 5


Database search filter - sabr - 02-07-2017

Hi Sorry have not been active, my project got scraped Sad

LBC, I think you may need to remove the initial code blocks and just have:

Code:
if($project == 1){
Code:
$project = '1';
Code:
}

Code:
if($volunteer == 1){
Code:
$volunteer = '1';
Code:
}

Then when it comes to returning the results you would have something like:

Code:
if(!empty($_POST)){
Code:
echo "<strong>Here's what we found under Volunteers...</strong><br>";
Code:
if(!empty($matches) && $volunteer == 1){
Code:
foreach ($matches as $m){
Code:
$foundQ = $db->query("SELECT * FROM users WHERE volunteer = 1 AND id = ?",($m));
Code:
$found = $foundQ->first();
Code:
echo '<a href="users/profile.php?id='.$found->id.'"'.'>'.$found->fname.' '.$found->lname.'</a><br>';
Code:
}
Code:
}else{
Code:
echo "Sorry. No users were found";
Code:
}
Code:
}
Code:
?>

Hopefully the syntax is correct and this returns the results you are after. If this works you can insert an elif for projects.


Database search filter - LBC - 02-07-2017

Hmm...that looks like you dropped all the other boxes. Or did you mean:

<pre>
Code:
if($project == 1){
$project = '1';
}
</pre>


<pre>
Code:
if($volunteer == 1){
$volunteer = '1';
}
</pre>


<pre>
Code:
if($small_animals == 'small animals'){
$small_animals = 'small animals';
}
</pre>


<pre>
Code:
if($large_animals == 'large_animals'){
$large_animals = 'large animals';
}
</pre>


etcetera etcetera...


Database search filter - sabr - 02-07-2017

Only Project and Volunteer code blocks are changed.

Small animals etc remains the same.


Database search filter - LBC - 02-07-2017

Nope...its not giving any results from project or volunteer search. ( array(0) {} )
It finds users from the other boxes but is not displaying them.


Database search filter - sabr - 02-07-2017

so after spending a bit of time setting up a test the solution is as follows:

Replace
Code:
$foundQ = $db->query("SELECT * FROM users WHERE volunteer = 1 AND id = ?",($m));

with
Code:
$foundQ = $db->query("SELECT * FROM users WHERE volunteer = '1' AND id = ?",($m));

notice the single quotes around the 1.

Works on my system so hopefully will work on yours. Smile




Database search filter - LBC - 02-08-2017

Thank you for your effort sabr, but I'm afraid it doesn't work.

When I now check the Project box alone it sees the user (id 99), but it doesnt display it in the results.
Code:
array(1) {
Code:
[0]=>
Code:
object(stdClass)#7 (1) {
Code:
["id"]=>
Code:
string(2) "99"
Code:
}
Code:
}

Also, when I check the Project box AND the Small Animals box it gives me the Volunteer users that have set Small Animals as an interest. When it should only give me the Project user.

I have sent mudmin all the data (sql and php) and he is taking a crack at it on his own system.

Fingers crossed Smile


Database search filter - sabr - 02-08-2017

My brain has just engaged and worked out why you are seeing this.
I can think of a complex way to solve this but would like to see what Mudmin comes up with. Smile