Simple Search Engine

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
RySk8er30
Forum Newbie
Posts: 5
Joined: Sat Nov 16, 2002 7:46 pm

Simple Search Engine

Post by RySk8er30 »

Hello,
I am very new to PHP and do not know MySQL, so I am trying to make a mini-search engine with just PHP. I have two questions, but first here is my code:

Code: Select all

<?php

if ($_POST&#1111;'search']=='computer' OR $_POST&#1111;'search']=='repair')  &#123;  

print ("<A HREF=/repair.html>IT Worked with computer repair</A>");


&#125;

?>


<?php

if ($_POST&#1111;'search']=="sales" OR $_POST&#1111;'search']=='computer')&#123;  

print ("<A HREF=/repair.html>IT Worked with computer sales</A>");

&#125;

?>


<?php

if ($_POST&#1111;'search']=='web' or $_POST&#1111;'search']=='design')&#123;  

print ("<A HREF=/repair.html>IT Worked with web design</A>");

&#125;

?>


<?php

if ($_POST&#1111;'search']=='hosting' or $_POST&#1111;'search']=='web')&#123;  

print ("<A HREF=/repair.html>IT Worked with web hosting</A>");

&#125;

?>
How do I make it so everything is not case sensitive. For example, currently if I search on my site for "Web", i will not get any results, but if i use "web" I will. Also is there an easier way of combining the two OR statements in each of the IF statements?
Thanks
Ryan
RySk8er30@Aol.com
User avatar
PaTTeR
Forum Commoner
Posts: 56
Joined: Wed Jul 10, 2002 7:39 am
Location: Bulgaria
Contact:

Post by PaTTeR »

Code: Select all

$_POST&#1111;'search'] = strtoupper($_POST&#1111;'search']);
And after this all your conditions must be in upper case

Code: Select all

if ($_POST&#1111;'search']=='COMPUTER' OR $_POST&#1111;'search']=='REPAIR') &#123;

................................
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

To save typing everything in uppercase it may be easier to use strtolower() instead of strtoupper(). That way everything will be lowercase and you can leave your conditions as they were.

Mac
Post Reply