Page 1 of 1

Simple Search Engine

Posted: Mon Nov 18, 2002 11:39 am
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

Posted: Mon Nov 18, 2002 1:23 pm
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;

................................

Posted: Tue Nov 19, 2002 6:25 am
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