I've been learning PHP in my free time for a couple of weeks and this is the first problem I have had to ask help with. I've searched all over the internet but have found nothing I can fully understand when it comes to having a PHP mysql search engine with two input fields.
I have a search engine, which has two input fields, one field is for entering the kind of business one is looking for. The second field is for entering the location which one is trying to find the business in.
Could someone awesome and highly intelligent please tell me how do I get:
The first input field to search through my business
column in my MySql table &
the second input field to search through my location
column in my MySql table.
I am using the FULLTEXT
search engine method.
Here is the form snippet: (I know it's really sloppy, and probably unsafe but I plan on fixing that later.)
<form id="tfnewsearch" method="get" action="search.php">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="476" border="0" cellspacing="0" cellpadding="0">
<tr valign="middle">
<td width="476" class="">
<div id="tfheader2">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="91%">
<table width="472" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="4"> </td>
<td width="139"><input style="width:210px" type="text" id="tfq" class="tftextinput2" name="business" size="20" maxlength="40" value="Business e.g. Insurance" onClick="if(this.value == 'Business e.g. Insurance') this.value='';" /></td>
<td width="5"> </td>
<td width="69"><input style="width:210px" type="text" id="tfq2" class="tftextinput2" name="location" size="20" maxlength="40" value="Location e.g. Hamilton" onClick="if(this.value == 'Location e.g. Hamilton') this.value='';" /></td>
<td width="4"> </td>
<td>
<input style="width:40px" type="image" src="site_images/q.png" alt="Search" class="tfbutton2" name="submit" value=">" />
</td>
<td width="10"> </td>
</tr>
</table>
</td>
</tr>
</table>
<div class="tfclear"></div>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
Here is the php snippet:
$button = @$_GET['submit'];
$search1 = @$_GET['business'];
$search2 = @$_GET['location'];
$strSQL = "SELECT * FROM users WHERE region = $search1 AND city = $search2";
$query = mysqli_query($con, $strSQL);
while ($result = mysqli_fetch_array($query));
if ($result = mysqli_query($con, $strSQL))
$foundnum = mysqli_num_rows($result);
if ($foundnum == 0)
If you need more info please let me know.