blink359 Posted December 23, 2010 Share Posted December 23, 2010 Hi there Im trying to add a search feature to my pagination but with some googling and searching have had no luck and have also had no luck trying myself this is what i have so far Form <form action="publist.php" method="post"> Search: <input type="text" name="search"> By: <select name="by"> <option value="name" selected="selected">Name</option> <option value="town">Town</option> <option value="county" >County</option> </select> Results Per Page: <select name="perpage"> <option value="10" selected="selected">10</option> <option value="25">25</option> <option value="50" >50</option> </select> <input type="hidden" name="hidden"> <input type="submit" value="Search"> </form> Related code: if(isset($_POST['hidden'])){ $by = $_POST['by']; $search = $_POST['search']; $sql = "SELECT * FROM table WHERE approved = 'Yes' AND '. $by .' = '. $search .' LIMIT $offset, $rowsperpage"; }else{ $sql = "SELECT * FROM table WHERE approved = 'Yes' LIMIT $offset, $rowsperpage"; } $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); while ($list = mysql_fetch_assoc($result)) { echo' <table width="700" border="1"> <tr> <td colspan="3">'. $list['name'] .'</td> </tr> <tr> <td height="24">Town: '. $list['town'] .'</td> <td>County: '. $list['county'] .'</td> <td>Postcode: '. $list['postcode'] .'</td> </tr> <tr> <td>Contact Number: '. $list['phone'] .'</td> <td>Email: '. $list['pubemail'] .'</td> <td><a href="info.php?id='. $list['ID'] .'">More Information</a></td> </tr> </table><br>'; } But when i try the search it comes out blank, Any help would be great Thanks, Blink359 Quote Link to comment https://forums.phpfreaks.com/topic/222495-pagination-search-problem/ Share on other sites More sharing options...
litebearer Posted December 23, 2010 Share Posted December 23, 2010 1. Are you getting any error messages? 2. have you tested your variables to check that they contain what you expect them to contain? Quote Link to comment https://forums.phpfreaks.com/topic/222495-pagination-search-problem/#findComment-1150744 Share on other sites More sharing options...
mmarif4u Posted December 23, 2010 Share Posted December 23, 2010 To make your life easier. http://www.raymondselda.com/php-pagination-script/ Quote Link to comment https://forums.phpfreaks.com/topic/222495-pagination-search-problem/#findComment-1150750 Share on other sites More sharing options...
blink359 Posted December 23, 2010 Author Share Posted December 23, 2010 I did check the variables, the do contain what there meant to but there is no error shown its just blank were the data should be everything else on the page is fine e.g the page navigation (e.g.<< < 1 2 3 4 > >>) Quote Link to comment https://forums.phpfreaks.com/topic/222495-pagination-search-problem/#findComment-1150754 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.