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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.