Jump to content

how would i go about adding a simple search to my pagination?


xfezz

Recommended Posts

Currently I have a pagination script that shows the content of my database. I want to be able to do a simple search in my database and display the results of the search with my pagination script. I dont want to redirect to another page for the search. I want to display the results of the search in place of displaying all the results in x pages.

I was thinking about doing something a long the lines of the following

[code]
$search = $_POST['txtSearch'];

if ($search == null) {
    // search field is null no search was performed, display all records
    $sql = "SELECT * FROM articles ORDER BY id DESC LIMIT $from, $max_results";
    $getlist = mysql_query($sql) or die(mysql_error());
}
else
{
    // a search was performed, display results of the search
    $sql = "SELECT * FROM articles WHERE message LIKE '%search%' ORDER BY id DESC LIMIT $from, $max_results";
    $getlist = mysql_query($sql) or die(mysql_error());
}
[/code]

im sure my syntax is a bit off on the search query but am i going in the right direction with this?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.