Search on my Website

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

Search on my Website

Post by RySk8er30 »

Hello,
I am trying to put a search engine on my website, but I do not have access to MySQL. Here is my current PHP Code:

Code: Select all

php

$_POSTї'search'] = strtoupper($_POSTї'search']); 



if ($_POSTї'search']=='COMPUTER' OR $_POSTї'search']=='REPAIR') {  

print ("<A HREF=/repair.html>IT Worked with computer repair</A>");
print ("<P>Big name companies do not have time to sit down and talk with a customer to fufill their computer needs. Here at PC First Aid, we realize the importance of a high-quality repair along with superior technical support. ");

&#125;



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

print ("<A HREF=/repair.html>IT Worked with computer sales</A>");
print ("Our sales department is like no other. We do not carry items in stock like other companies, we actually browse the web for the lowest cost product to insure customer satisfaction.");
&#125;




if ($_POST&#1111;'search']=='WEB' or $_POST&#1111;'search']=='DESIGN')&#123;  

print ("<A HREF=/repair.html>IT Worked with web design</A>");
print ("In the 21st century, business do not have time to hire employees for web design. Here at PC First Aid, we provide this service at a minimal fee.");
&#125;



if ($_POST&#1111;'search']=='HOSTING' or $_POST&#1111;'search']=='WEB')&#123;  

print ("<A HREF=/repair.html>IT Worked with web hosting</A>");
print ("We provide low-cost, high-quality web hosting with numerous features. Choose from a variety of three plans that best suit your needs. </P>");
&#125;
I was wondering if there was any easier ways of doing this because if you put in web hosting, nothing comes up, but if you put web it does. Thanks.
Ryan
RySK8er30@Aol.com
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

tip

Post by AVATAr »

this:
if ($_POST['search']=='HOSTING' or $_POST['search']=='WEB'){

will never return true if $_POST="WEB HOSTING"...

you have to parse the $_POST and search for each word
RySk8er30
Forum Newbie
Posts: 5
Joined: Sat Nov 16, 2002 7:46 pm

Still confused...

Post by RySk8er30 »

Hello,
What do you mean you have to "phrase the $_POST"? Do you mean:

Code: Select all

if ($_POST&#1111;'search']=='HOSTING' or $_POST&#1111;'search']=='WEB HOSTING')&#123;
Is there a shorter way to write this? Is there a better way to code this?
Ryan
RySk8er30
User avatar
PaTTeR
Forum Commoner
Posts: 56
Joined: Wed Jul 10, 2002 7:39 am
Location: Bulgaria
Contact:

Post by PaTTeR »

Yes, there is a better way - using Regular Expression Functions
http://www.php.net/manual/en/ref.pcre.php
http://www.php.net/manual/en/ref.regex.php

Code: Select all

if (eregi("web|hosting",$_POST&#1111;'search'])) &#123;
    do something
&#125;
Code above match WebHostng ,Web hosTing ... case insensetive
Post Reply