Custom search form with Jumi

A multipurpose module, plugin and component

Custom search form with Jumi

New postby drunkenphd » Tue Jan 28, 2014 6:46 pm

Hi
I want to create a custom search form using Jumi.
This form should contain input boxes for name surname so I can search by these two fields.
I want to use this two fields in a SQL query so I can output my results with an extension I purchased ArtData.
Can you help me with some code ?
Regards
drunkenphd
 
Posts: 1
Joined: Tue Jan 28, 2014 6:43 pm

Re: Custom search form with Jumi

New postby fiegri » Thu Jan 30, 2014 8:05 pm

Try something like this:

Put this code in a page :
Code: Select all
   <form action="/pagetoshowresults.html" method="get" id="search">
         <p><input tye="submit" type="text" value="<? echo htmlentities($q); ?>"/  name="q" placeholder="search here..." width=600px /></p>




In a second page (pagetoshowresults.html) write something like this:
Code: Select all
<?
$q = isset($_GET['q'])?$_GET['q']:'';

if (empty($q)) {
echo "You Search string is empty";
}

else {
$db = JFactory::getDbo();
$query= "SELECT * from YOURTABLE where WHATAREYOULOOKINGFOR like '%$q%'"; 
// THE QUEY IS VERY PERSONAL. YOU SHOULD USE 'LIKE', OR '=' OR 'MATCH AGAINST' METHOD
$db->setQuery($query);
$results = $db->loadObjectList();


foreach ($results as $prod) {
echo $title = ($prod->title);
echo $ID = ($prod->ID);
// HERE YOU NEED TO PARSE THE RESULTS
}

?>


I suggest you sphinx search engine. (look here: http://www.bikeshopitalia.com/search-engine.html)

Bye
Fabio
fiegri
 
Posts: 4
Joined: Mon Feb 25, 2013 8:57 pm


Return to Jumi

Who is online

Users browsing this forum: No registered users and 3 guests

cron