Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


Creating a search in multiple fields


Creating a search in multiple fields



";



while($row=mysql_fetch_assoc($result)){



echo "$display_block";



echo '
Author
Message
ippbx
ippbx
Forum God
Forum God (435 reputation)Forum God (435 reputation)Forum God (435 reputation)Forum God (435 reputation)Forum God (435 reputation)Forum God (435 reputation)Forum God (435 reputation)Forum God (435 reputation)Forum God (435 reputation)

Group: Forum Members
Posts: 1, Visits: 2
I have used your search-keyword.php tutorial and have tried to modify it to allow for search in multiple fields. I have a table that list the following:



id, mentee1, senior1, junior1, mentee2, senior2, junior2, mentee3, senior3, junior3, mentee4, senior4, junior4, mentee5, senior5, junior5 (and a few others that are not important)



Except for the "id" all are names of individuals and can show up in all fields and more than one field ie J Smith can be a mentee1 and a junior3.



I would like to search for J Smith and find him in all the entries.



Here is how I have wrongly modified the code:



Code: Select all


include("connectdb.php");



$todo=$_POST['todo'];

if(isset($todo) and $todo=="search"){

$search_text=$_POST['search_text'];

$type=$_POST['type'];



$search_text=ltrim($search_text);

$search_text=rtrim($search_text);



if($type<>"any"){

$query="select * from test where mentee1 and senior1 and junior1 and mentee2 and senior2 and junior2 and mentee3 and senior3 and junior3 and mentee4 and senior4 and junior4 and mentee5 and senior5 and junior5='$search_text'";

}else{

$kt=split(" ",$search_text);//Breaking the string to array of words

// Now let us generate the sql

while(list($key,$val)=each($kt)){

if($val<>" " and strlen($val) > 0){$q .= " mentee1 and senior1 and junior1 and mentee2 and senior2 and junior2 and mentee3 and senior3 and junior3 and mentee4 and senior4 and junior4 and mentee5 and senior5 and junior5 like '%$val%' or ";}



}// end of while

$q=substr($q,0,(strLen($q)-3));

// this will remove the last or from the string.

$query="select * from test where $q ";

} // end of if else based on type value

echo $query;

echo "

";

$nt=mysql_query($query);

echo mysql_error();

while($row=mysql_fetch_array($nt)){




$id$mentee1$senior1$junior1$mentee2$senior2$junior2$mentee3$senior3$junior3$mentee4$senior4$junior4$mentee5$senior5$junior5
Update
';



echo "
";

}

// End if form submitted



}else{

echo "






";

Call center software I Phone number



GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search