View Full Version : my search box isn't working?!

07-30-2008, 12:00 PM
All i get is a blank screen

html form:

<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" />



$Searchresult = $_GET['hsearch'];?>


// 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
$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);
while($row = mysql_fetch_array($result)){
echo "animatedcollapse.addDiv('jason$i', 'hide=1', 'fade=1,height=180px')\n";

07-30-2008, 12:11 PM
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.