Yesideez Posted November 18, 2006 Share Posted November 18, 2006 First, here's some code:[code] switch ($searchrule) { case 1:$rulemysql="LIKE '%".$usrsearch."'";break; case 2:$rulemysql="LIKE '".$usrsearch."%'";break; case 3:$rulemysql="LIKE '".$usrsearch."'";break; default:$rulemysql="LIKE '%".$usrsearch."%'"; }[/code][code] $resultshtml=""; if ($flagpowercodes) { $resultshtml.='<strong>Power Codes</strong><br />'."\n"; $found=countmatches("`matches` FROM powercodes WHERE (`area` ".$rulemysql.") OR (`counties` ".$rulemysql.") ORDER BY `codeid` ASC"); if ($found>0) { $resulthtml='<table cellspacing="0" cellpadding="2" class="outside">'."\n".'<tr class="tbltr"><td class="tblhdr">Area</td><td class="tblhdr">Counties</td><td class="tblhdr">Code</td><td class="tblhdr" width="62">Times</td></tr>'."\n"; $resulthtml.='<tr class="tbltr"><td class="gtext">Found: '.$found.'</td></tr>'."\n".'</table>'."\n"; } else { $resultshtml.='Nothing found.'."\n"; } }[/code][code] function countmatches($query) { echo "SELECT COUNT(*) AS ".$query."<br />"; $fetch=mysql_fetch_array(mysql_query("SELECT COUNT(*) AS ".$query)); return intval($fetch['matches']); }[/code]Here's a sample of what the query looks like:[code]SELECT COUNT(*) AS `matches` FROM `powercodes` WHERE (`area` LIKE '%london%') OR (`counties` LIKE '%london%') ORDER BY `codeid` ASC[/code]If I omit the OR and the second condition I get 3 returned but as it is now, this gives nothing no matter what I look for. Any ideas? Quote Link to comment Share on other sites More sharing options...
Yesideez Posted November 18, 2006 Author Share Posted November 18, 2006 [b]PROBLEM SORTED[/b]I've re-written a large section of the code and it all now works fine. I guess that'll teach me for writing too much code for too long a time. Couldn't see the "wood for the trees" kind of thing. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.