PHP forums, MySQL forums, Web Development resources

Home PageHome    PHP ResourcesTopic List    FAQFAQ    SearchSearch    MemberlistMemberlist    UsergroupsUsergroups 
 RegisterRegister
    ProfileProfile    Log in to check your private messagesLog in to check your private messages    Download the RSS Reader RSS Feed Download the RSS Reader RSS for this forum Log inLog in 

PHP Forum :: MySQL Forum :: Java Script Forum



2 Problems with PHP3&MySQL

 
Post new topic   Reply to topic    WeberForums.com Forum Index -> PHP General
View previous topic :: View next topic  
Author Message
Valerio Fioretti
Guest





PostPosted: Sat Jan 30, 1999 6:18 pm    Post subject: 2 Problems with PHP3&MySQL Reply with quote

Hi, I've some troubles in making a search engine for a web site:
1) I don't know how to make a boolean search (AND/OR) using 2 or more inputs taken from only one field in a search form. Example: I write in the field "TEST FILE". Actualy the engine look for both togheter, I'd like to have a search for "TEST" "FILE" and "TEST FILE".

2) If there's no data matching the input I get a "0 in not a mysql ......." or "The document contain no data"
How can I show a message to the user instead of these ?


THANKS A LOT
Valerio
Back to top
Boaz Yahav
Guest





PostPosted: Sat Jan 30, 1999 10:52 pm    Post subject: RE: 2 Problems with PHP3&MySQL Reply with quote

Hi

Both questions seem simple enough :

1. Lets say the form parameter is called "search". When someone does the search for "TEST FILE" you get a variable called $search which has a value of "TEST FILE".
All you need to do now is get the word "TEST" and the word "FILE" out of the string. You can do this like this :

$WORDS=explode(" ", $search);

Now you have an array which has the word "TEST" in $WORDS[0] and the word "FILE" in $WORDS[1].

Now you need to make a query for each of the words and a query for the original $search string.

2. before you do anything, check to see if the query returned any data. if you work with MySql you just need to do :

$query=mysql_query("SELECT * FROM.....") or die("Can't Preform query");
if (!mysql_num_rows($query))
echo"no results found"
else....


This is the general idea but you will need to make some kind of counter cause you will have more than one query. if the counter will still be 0 after the last query then you can echo a message about no results...

hope this helps


berber
Back to top
Display posts from previous:   
WeberTrivia Questions WeberTrivia Questions
 Think you are smart? Prove it!. Try your skills with these questions :
 WeberTrivia QuestionsRecursive arrays and multi-dimensional arrays are one and the same. (PHP and MySQL)
 WeberTrivia QuestionsThe \"cache_dir\" tag of the squid configuration has a default of /var/spool/squid. (Linux)

WeberTrivia Questions



Post new topic   Reply to topic    WeberForums.com Forum Index -> PHP General All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum






Powered by phpBB © 2001, 2005 phpBB Group
PHP Forum :: MySQL Forum :: Java Script Forum