Your search function sounds very similar to how I implemented mine. Because I’m using a textfield to supply the term to search for, I looked online for any information regarding the risks involved etc...and found
http://www.roscripts.com/PHP_search_engine-119.html which is what I based my search function on.
I’m also not a lawyer, so I’m not sure about the rest either. I hope you understand that I don’t really want to tell them I’m going to release the ( also pretty minor PHP skills ) script contrary to their wishes, not least because they have a lot of say in an on-going project that pays my bills every month.
I can however talk you through my approach and then if you have any questions about parts of it, I would be pleased to assist where I can.
Pagination:
I’m passing a variable called pag in the url, if it’s undefined or non-numeric the script defaults to 0
I have a variable which defines how many pages to display either side of the current page.
I then do
$modx->db->query("SELECT id FROM ".$web_users);
This could possibly be improved upon for speed? Using mysql_num_rows I now know how many users I have
As described on the first page I have a this->Pagination which I divide the number of users by, to find out how many pages I am going to have.
I need to keep note of the current page number too, which is nothing more than the value of "pag" divided by this->Pagination
If the pageNumber - the number of pages we are displaying is greater than 1 we need to output arrows at the beginning.
One to jump to the first page of pagination using $modx->documentIdentifier."&pag=0"
And one to jump to the page before the first one visible. So say for example we are displaying 5 pages and are on page 12, it would link to page 6. This was the biggest nightmare of the entire script.
$beforePaginationOutput.="<a class=\"jumpToOneless\" title=\"Jump to page ".($pageNumber-$numberDisplayed-1)."\" href=\"index.php?id=".$modx->documentIdentifier."&pag=".(($pageNumber-$numberDisplayed-1)*$this->Pagination-$this->Pagination)."\"><</a> ";
The script after pagination works in exactly the same way (but reversed

)
I then loop thru beginning at either 1 (if we arent at a page greater than numberDisplayed) otherwise at pageNumber - numberDisplayed
for($i=$startIncr;$i<=$pageNumber;$i++){
$startPos = $i*$this->Pagination-$this->Pagination;
if($startPos !=$positionInList){
$output.=" <a href=\"index.php?id=".$modx->documentIdentifier."&pag=".$startPos."\">".$i."</a>";
}
else{
//We've looped thru right up to the current page.
//You could also add a here class to the output if you wish
$output.=" ".$i;
}
}
Similar code is then used for after the current page.
All that is left now, is to query the database to grab the users to display on the current page.
$fetchUsers = $modx->db->query("SELECT `username` FROM ".$web_users."LIMIT ".$positionInList.",".$this->Pagination);
All we need to do now is output the data, which is easy using Scottys
$this->FetchAll($fetchUsers)
Cheers,
Taff