Archive for April 14th, 2005
write better search engine in php
April 14th, 2005
my limited mysql knowledge always produced inaccurate search results when i write the board search engine. i want to do better this time for the new board so i’m reading this and trying out mysql regular expression and full text search. i’m pretty excited.
oh also, leslie reminded me. this perl style coding will save you from using back slashes and stuff like
<?=$var?>
PHP CODE:
i<?php
f(isset($j_sidebar)) {
echo <<<EOF
<div id="side">
{$j_sidebar}
</div>
<!--/side-->
EOF;
}
echo <<<EOF
<div id="main">
{$j_main}
</div><!--/main-->
</div><!--/outer-->
</body>
</html>
EOF;
?>
vs.
PHP CODE:
if(isset($j_sidebar)) {
echo "<div id=\"side\"> $j_sidebar </div><!--side-->";
}
echo "<div id=\"main\"> $j_main </div><!--/main--> </div><!--/outer--> </body> </html>";
i’ve been using the second for too long, it’s hard to change but it certainly doesn’t hurt to try something different
hehe another tip from leslie, you can insert multiple records into one table using just one query:
INSERT INTO blah (blah, blah) VALUES (blah, blah), (blah, blah), ....

