Hi all,
Just wondering if someone can help me with the following:
I have a site for which I want to add a search box; whereby which users can search for people based on the following criteria: Name/Pin/Keyword
I'm new to PHP and MySQL; therefore any help will be much appreciated.
Search Form
Moderator: General Moderators
Re: Search Form
Code: Select all
$query = "SELECT * FROM `someTable` WHERE `name` LIKE '".mysql_escape_string($_POST['searchField'])."%' OR `pin` LIKE '".mysql_escape_string($_POST['searchField'])."%' OR `keyword` LIKE '".mysql_escape_string($_POST['searchField'])."%'";
Re: Search Form
Hi,
I needed it taking down to the basics.
I need to add the search box and the necessary fields to the HTML and from there I'm not sure of what I need to do next.
Do I need to create a file for the MySQL db? and then how does that translate to the search form?
Thanks and sorry for the numpty questions!!!
I needed it taking down to the basics.
I need to add the search box and the necessary fields to the HTML and from there I'm not sure of what I need to do next.
Do I need to create a file for the MySQL db? and then how does that translate to the search form?
Thanks and sorry for the numpty questions!!!
Re: Search Form
Code: Select all
<form method="post">
<input type="text" name="searchField">
<input type="submit" value="search">
Code: Select all
<?php
if(isset($_POST['search']))
{
// use the query I gave you before
}