I'm trying to build a simple search facility for a products list on my site. I was given a function by someone but i'm not altogether sure what i need to do with it.
this is what i've got for search.php:
<?php
include 'db.php';
require 'functions.php';
pagetop(Searcher, $accepted, $username);
function searchActiveProducts($field, $searchstr, $from = 0, $to = 9999) {
$products = array();
$sql = "SELECT * from products where $field LIKE '%$searchstr%' limit $from, $to";
$result = @mysql_query($sql);
if ( $result == false )
{
/* echo @mysql_error(); */
}
else
{
$result = @mysql_query( $sql );
if ( $result != false ) {
while(($record = @mysql_fetch_assoc($result))) {
array_push ($products, $record);
}
}
}
@mysql_free_result($result);
@mysql_close($dbconn);
return $products;
}
?>
<FORM NAME='search' METHOD='GET' ACTION='searchresults.php?page=1'>
Search our Catalog:<BR>
<SELECT NAME='searchby'>
<OPTION VALUE='printer'>Printer
<OPTION VALUE='brand'>Brand
</SELECT>
<INPUT TYPE='TEXT' NAME='searchstr' SIZE='20' MAXLENGTH='30' VALUE=''>
<INPUT TYPE='submit' VALUE='Go'>
</FORM>
<?
pagebottom();
?>
This is passing info to searchresults.php like this:
searchresults.php?searchby=brand&searchstr=epson
Not too sure what i need to be doing within this page to display the results, presuming the function is called from functions.php, do i just need to call the function, and whats the deal with array_push?
any help would be much appreciated.