Jump to content

Pagination + Search problem


blink359

Recommended Posts

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

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.