Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Banned
    Join Date
    Mar 2007
    Posts
    1,523
    Thanks
    116
    Thanked 0 Times in 0 Posts

    my search box isn't working?!

    All i get is a blank screen

    html form:
    Code:
    <form action="search_results.php" class="searchform" method="POST" name="search">
    				<input type="textbox" value="Search" name="hsearch" class="searchbox" onFocus="document.forms['search'].elements['hsearch'].value = ''" onBlur="document.forms['search'].elements['hsearch'].value = 'Search'" />
      				<input name="hsearch" class="button" value="Search" type="submit" />		
        </form>
    php
    Code:
    <?php
    
    $Searchresult = $_GET['hsearch'];?>
    
    
    <?php
    
    // how many rows to show per page
    $rowsPerPage = 20;
    
    // by default we show first page
    $pageNum = 1;
    
    // if $_GET['page'] defined, use it as page number
    if(isset($_GET['page']))
    {
    	$pageNum = $_GET['page'];
    }
    
    // counting the offset
    $offset = ($pageNum - 1) * $rowsPerPage;
    
    $query  = "SELECT * FROM Headertbl WHERE HeaderName like %".$Searchresult."% ORDER BY HeaderDate DESC LIMIT $offset, $rowsPerPage";
    $result = mysql_query($query) or die(mysql_error().'<br>SQL: ' . $query);  
    $i=0;
    while($row = mysql_fetch_array($result)){
    	echo "animatedcollapse.addDiv('jason$i', 'hide=1', 'fade=1,height=180px')\n";
    	$i++;
    }
    ?>

  • #2
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,303
    Thanks
    4
    Thanked 204 Times in 201 Posts
    In your HTML form you are using the same name for both your input field for search data and the submit button. Your form is also using POST but you are retrieving the values from the form using $_GET.

    Try changing the name of your submit button and change $_GET to $_POST and see if you get the expected results.
    Dave .... HostMonster for all of your hosting needs


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •