Find jobs - Credit Card - Business Gifts - Find jobs - Debt Consolidation

PDA

View Full Version : Keyword search box?


le007
Oct 1st 2007, 1:53 pm
How can I have a keyword search box - that you can actually type in a word and search for associated results?
Thanks

nico_swd
Oct 1st 2007, 2:00 pm
Where is the content stored?

le007
Oct 1st 2007, 3:01 pm
Its stored in a database - any example of code would be classic!

nico_swd
Oct 1st 2007, 3:12 pm
I'll point you in the right direction, but you have to do the rest yourself. :D



if (!empty($_REQUEST['keyword']))
{
$query = mysql_query("
SELECT *
FROM table_name
WHERE field_name LIKE '%" . mysql_real_escape_string($_REQUEST['keyword']) . "%'
") OR die(mysql_error());

while ($result = mysql_fetch_assoc($query))
{
echo $result['field_name'], "<br />\n";
}

if (!$result)
{
echo 'No results found';
}
}

le007
Oct 1st 2007, 3:29 pm
Thats really class, thanks for that!!! I'll have a go!

khan11
Oct 1st 2007, 3:53 pm
well, is their any code to search inside an array using $_GET OR POST?

like we have 10 elements in an array: if we search a word of element a it will give us element a as result

nico_swd
Oct 1st 2007, 4:21 pm
^^ Please start your own thread for separate questions that don't have anything to do with the original topic.