Jump to content

Search Boxes


pablo1988

Recommended Posts

I am trying to add two search boxes to the below code. I need First Name, Last Name and Skill. I have added the boxes and connected fname (first_name) but am not sure how to link the other two correctly. Can anybody please help? I think it's something to do with the bold red text.

 

Thanks

 

<h3>Search  Contacts Details</h3>

<p>You  may search either by first or last name</p>

<form  method="post" action="a.php?go"  id="searchform">

<input  type="text" name="fname">

<input  type="text" name="lname">

<input  type="text" name="skill">

<input  type="submit" name="submit" value="Search">

</form>

 

<?php

 

if(isset($_POST['submit'])){

if(isset($_GET['go'])){

if(preg_match("/^[  a-zA-Z]+/", $_POST['fname'])){

$fname=$_POST['fname'];

   

//connect  to the database

$db=mysql_connect  ("127.0.0.1", "root",  "") or die ('I cannot connect to the database  because: ' . mysql_error());

   

//select  the database to use

$mydb=mysql_select_db("resource matrix");

   

 

//query  the database table

$sql="SELECT DISTINCT First_Name, Last_Name, l.Resource_ID FROM ((resource l inner join resource_skill ln on l.Resource_ID = ln.Resource_ID) inner join skill n on ln.Skill_ID = n.Skill_ID) WHERE First_Name LIKE '%" . $fname .  "%' OR Last_Name LIKE '%" . $lname ."%' OR Skill_Name LIKE '%" . $skill ."%'";

   

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.