phpretard Posted January 27, 2009 Share Posted January 27, 2009 This only displays one result and I can't figure out why... There are 2 fields in the DB I am trying to search through and look for the keyword typed in the search field: FIELD 1:casetype VARCHAR FIELD 2:caseinfo TEXT I can get it search and display all when search one field at a time but it only dispalys one result if I try to search both fields. $find=$_POST['find']; $data = mysql_query("SELECT * FROM cases WHERE (casetype or caseinfo LIKE'%$find%') "); while($result = mysql_fetch_array($data)) { $id=$result['id']; echo "<h1>".$result['casetype']."</h1>"; echo "<hr />"; $caseinfo=$result['caseinfo']; $caseinfofull=$result['caseinfo']; echo"<div id='$id' style='display:none'>$caseinfofull [<a href='javascript:void(0)' onclick=\"Hide('$id'), Show('partial$id')\">close</a>]</div>"; echo "<div id='partial$id' style='display:block'>".$shortdesc = substr_replace($caseinfo, '', 400, -1) . "... <a href='javascript:void(0)' onclick=\"Show('$id'), Hide('partial$id')\">read more</a></div>"; echo "<br>"; echo "<br>"; } Link to comment https://forums.phpfreaks.com/topic/142649-solved-search-db-help/ Share on other sites More sharing options...
kwstephenchan Posted January 27, 2009 Share Posted January 27, 2009 try to apply %LIKE% on both field not just one. Link to comment https://forums.phpfreaks.com/topic/142649-solved-search-db-help/#findComment-747678 Share on other sites More sharing options...
phpretard Posted January 27, 2009 Author Share Posted January 27, 2009 Bouya! Link to comment https://forums.phpfreaks.com/topic/142649-solved-search-db-help/#findComment-747681 Share on other sites More sharing options...
phpretard Posted January 27, 2009 Author Share Posted January 27, 2009 Basically the same as my first question but I noticed if I search with more than one word it returns nothing. $find="ONE"; // WORKS GREAT $find="TWO WORDS"; // NO RESULTS ... I KNOW THERE IN THE DB THOUGH $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); $data = mysql_query("SELECT * FROM cases WHERE (casetype LIKE '%$find%') OR (caseinfo LIKE '%$find%') "); while($result = mysql_fetch_array($data)) { echo "<h1>".$result['casetype']."</h1>"; echo "<hr />"; $caseinfo=$result['caseinfo']; $caseinfofull=$result['caseinfo']; echo $caseinfofull; echo $shortdesc = substr_replace($caseinfo, '', 400, -1) . "; echo "<br>"; echo "<br>"; } Link to comment https://forums.phpfreaks.com/topic/142649-solved-search-db-help/#findComment-747776 Share on other sites More sharing options...
phpretard Posted January 27, 2009 Author Share Posted January 27, 2009 help? Link to comment https://forums.phpfreaks.com/topic/142649-solved-search-db-help/#findComment-747823 Share on other sites More sharing options...
phpretard Posted January 28, 2009 Author Share Posted January 28, 2009 help? Link to comment https://forums.phpfreaks.com/topic/142649-solved-search-db-help/#findComment-748381 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.