xfezz Posted November 5, 2006 Share Posted November 5, 2006 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.