Jump to content

Item Searching


Stotty

Recommended Posts

Right im quite new to PHP and im making a new website and i need a little tool on it

 

Like this

 

http://www.zybez.net/items.php

 

But not as High complex as that

 

All i need is a blank form like this on homepage

 

Saying Search : Form Here

 

then under that in a table displays 3 random items from the database

 

then when u search it searches by letter Like say i had one Called PHP Freaks

 

i could type P to get to it not the Hole word like PHP Freaks

 

im willing to give donations ( when my site starts getting )  to whoever can make it full credit

 

Thank you in advanced

Link to comment
https://forums.phpfreaks.com/topic/138462-item-searching/
Share on other sites

Stotty

 

You will need wildcard matching.  Assuming you're searching for an organization name in a database...

 

<?php   

$search = htmlspecialchars($_GET['searchfield']);

 

if (!get_magic_quotes_gpc())

{

  $search = addslashes($search);

}

 

$words = explode(" ", $search);

$phrase = implode("%' AND organization LIKE '%", $words);

   

$query = "SELECT organization, contactname, contacttitle from organization where organization like '%$phrase%'";

$result = mysql_query($query) or die('Could not query database at this time');   

 

?>

 

Deon

Link to comment
https://forums.phpfreaks.com/topic/138462-item-searching/#findComment-726150
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.