Helpful Information
Category: Simple Questions
Simple Questions -> Search

Hey guys,

I got a few problems which I have not been able to work out. I am using the Pagination Class from firepages -> The reason I am posting this, will be explained later on in this topic.

There's a few things that I want. I am admin on an IPB Board and the guys who set it up are beginners, so I wanted to create a more user friendly admin page with only the functions they will be using. So I am getting data from the IPB tables in the database, and I am looking for someone who can help me with a simple search function. I will be using the ipb_error_logs table for this example. Doesn't really matter which table I'll be using, as long as someone can help me a bit with the search function. I am using the following right now:

if (isset($_POST['search'])) {
} else {
$search = ("");

if (isset($_POST['field'])) {
} else {
$field = ("lod_id");

$max = mysql_result( mysql_query("SELECT COUNT(log_id) FROM ipb_error_logs WHERE $field LIKE '%$search%' ORDER by $field DESC"), 0 ) ;

$sql = mysql_query("SELECT * FROM ipb_error_logs WHERE $field LIKE '%$search%' ORDER by $field DESC LIMIT ".$pager->get_limit());


So you can see it's in combination with firepages' pagination class. This works, up to a certain point. It works when searching for an IP Adress, and an error code, but not when looking for a name. That is because the ID of the person is logged, and the name is in another table. I am sure you know what I mean. How would I make sure I can search for a name, rather than an ID of a person?

Problem 2
When getting the results, it all works fine, it will display the right amount of pages (ie Page 1 of 2 instead of Page 1 of 5). But when I click on NEXT, to go to the next page, it will display Page 1 of 5 again, and my search is gone. It needs to be remembered (for lack of a better word) so when I click next to see the next results, it will display Page 2 of 2.

It needs to be simple, I only need it to work. I will not be using this on a live webpage or in public, it's only accesible for IPB admins, so I do not care about security of the script and so on, I simply need it to work. If someone can provide me some easy steps (I do not really need the code per se, just need to know how to do it, really) it will be much appreciated !

Edit: The reason why this is so important, is that I really need the search function to work properly, so they can easily use it to search in the log database. I will not only be using this for the error logs, but also for the moderator logs, and they really need to keep track of all those logs in an easy way.


see here;

see here;

Did not answer any of my questions.

Does your paging work without you fiddling?
Does your search work without you fiddling?

If yes to both, why would you be having a problem?

Maybe there's someone who can actually help me by giving me some decent answers to my questions, because this is not helping.

Please post your non-working code...
You may very well have a query error in the paging code you copied?
That tid bit you posted doesn't help me or anyone else help you.
Have you tried a different paging class (

I appreciate you trying to help me, but you don't seem to understand. I'll try to describe it a bit simpler.

First issue, when I want to search in the error logs table for a name, I cannot, because instead of names there are id's. The actual name is in another table. How would I manage to search for a name?

Second issue, if I display my results, and there are 10 pages, when I search for something specific, it returns 5 pages for example. But, if I go to the next page, it returns the 10 pages. For example:

This is the actual list:

Page 1 of 10

When I now search for something, it returns the following:

Page 1 of 5

But, when I go to the next or previous page, it's back to Page 1 of 10. It does not "remember my search". Any ideas on how to fix this?

When you search you're filtering your data by what you've searched for

1 John ...
2 Joe ...
3 Jack ...
4 Amy ...
5 Bob ...
I search for J I get

Page 1 of 3
'cause there's only 3 filtered results, yes or no?

Either way post your page, let's see where the break down is.

To search for name, your query needs to include that field;

$sql = mysql_query("SELECT * FROM table_where_name_exists WHERE $field LIKE '%$search%' ORDER by $field

Is there nobody who understands what I am asking? :)