Jump to content

SQL Query in PHP for search funct.


patelp7

Recommended Posts

i am trying to do a query in php but it involves many conditions and am having difficulties...

 

I am trying...

 

$query = "select Subject, Description from Bulletin where ";

if (($searchSublen >0)){

$query .=" Subject like '%$searchSub%'";

$querycontent =1;

 

}elseif ($searchSublen ==0){

$errorstring .="<br>Subject Field contained no words<br>";

$error = $error +1;

}

 

if ($searchDesclen > 0){

if ($querycontent ==1) {

$query .= " Description like '%$searchDesc%'";

$querycontent = 1;

}else{

$query .="Description like '%$searchDesc%'";

$querycontent = 1;

}

 

But I need the following coditions...

 

select B.Subject, B.Description from Bulletin B, Relative R

where

Subject like '%$searchSub%'",

Description like '%$searchDesc%'"

B.Adminusername = R.Adminusername

AND

R.Username = '".$_SESSION['Username']."';

 

Would this be a valid query?

 

it is for a search function

Link to comment
https://forums.phpfreaks.com/topic/42379-sql-query-in-php-for-search-funct/
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.