geeky · php code

write better search engine in php

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:

<?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>";</code>

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), ....

4 thoughts on “write better search engine in php

  1. You blow my mind Dodo! Remember a few years ago you came to my site, still innocent, virgin from the binaries. Now here I am bowing to you, a code-goddess! :upsidedown:

  2. The reason I prefer the latter (though I did know about the first one. :3) is because I think it makes the code lots more organized looking. I even use even more echos – I close to never have any line breaks inside my echos because it messes up the pretty code. xD

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s