patelp7 Posted March 12, 2007 Share Posted March 12, 2007 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 More sharing options...
pikemsu28 Posted March 12, 2007 Share Posted March 12, 2007 can you post all your code? Link to comment https://forums.phpfreaks.com/topic/42379-sql-query-in-php-for-search-funct/#findComment-205570 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.