[PHP] Re: multiple search

2002-07-23 Thread JJ Harrison

After executing the exact script I get the following (rough)error:

Warning: Undefined offset: 1 in :/Inetpub/co2_busters_mk2

The script(Which is being executed about 25m away) soon cause my computer to
fill up up it's memory(96mb used to about 256)
That is why I couldn't give you the message(IE crashed).

It is looping forever for some reason(I've never filled a client's computer
that fast before!)

How can I fix it?

Or if you cant tell me what does the error mean?


--
JJ Harrison
[EMAIL PROTECTED]
www.tececo.com



Richard Lynch [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]...
 My question is what can I do if someone searches for php script for
search?
 
 I would want to use OR in my SQL statment. The problem is how do I write
the
 query so that it will detect the number of words sent then put enough ORs
 and LIKE '%$search[1]% in?

 The LIKE operator will cheerfully return 1 or 0, which you can add up,
or
 in your case, weight and add up in your SELECT:

 $query = select 0 ;
 # The 0 is a kind of 'yeast' to start off our summation of matches.

 $words = explode(' ', $search);

 while (list(,$word) = $words){
   $word = trim($word);
   if ($word){
 $query .=  + article_keyword.weight * article_keyword.keyword like
 '%$word%' ;
   }
 }

 $query .=  as score ;
 $query .=  from article_keyword, article_data ;
 $query .=  where score  0 ;
 $query .=and article_data.aid = article_keyword.aid ;
 $query .=  order by score desc ;

 echo $query, BR\n;

 --
 Like Music?  http://l-i-e.com/artists.htm




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: multiple search

2002-07-22 Thread Richard Lynch

My question is what can I do if someone searches for php script for search?

I would want to use OR in my SQL statment. The problem is how do I write the
query so that it will detect the number of words sent then put enough ORs
and LIKE '%$search[1]% in?

The LIKE operator will cheerfully return 1 or 0, which you can add up, or
in your case, weight and add up in your SELECT:

$query = select 0 ;
# The 0 is a kind of 'yeast' to start off our summation of matches.

$words = explode(' ', $search);

while (list(,$word) = $words){
  $word = trim($word);
  if ($word){
$query .=  + article_keyword.weight * article_keyword.keyword like
'%$word%' ;
  }
}

$query .=  as score ;
$query .=  from article_keyword, article_data ;
$query .=  where score  0 ;
$query .=and article_data.aid = article_keyword.aid ;
$query .=  order by score desc ;

echo $query, BR\n;

-- 
Like Music?  http://l-i-e.com/artists.htm


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: Multiple search options...

2001-08-03 Thread Richard Lynch

 Now I can do one or two of these seperate but can anyone suggest a logic
to
 take to allow someone to say: I'd like to search for Computer Programmers
 between 1 and 3 years experience in Kitchener and that have these
keywords.

 But the next person may come and say I want Computer Programmers with 2
 years experience in any city and any keywords...

MySQL:
create table programmer(
programmer_id int(11) auto_increment not null primary key,
category int(4),
experience int(2),
location varchar(255),
name text,
email text
);

create table category(
category_id int(11) auto_increment not null primary key,
category varchar(255)
);
insert into category(category) values('Computer Programmer');

insert into programmer(category, experience, location, name, email)
values(1, 5, 'Chicago', 'Richard Lynch', '[EMAIL PROTECTED]');

create table skill(
skill_id int(11) auto_increment not null primary key,
skill varchar(255)
);
insert into skill(skill) values('PHP');
insert into skill(skill) values('MySQL');
insert into skill(skill) values('PostgreSQL');

create table programmer_skill(
programmer_id int(11),
skill_id int(11)
);
insert into programmer_skill(programmer_id, skill_id) values(1, 1);
insert into programmer_skill(programmer_id, skill_id) values(1, 2);
insert into programmer_skill(programmer_id, skill_id) values(1, 3);

PHP:
$query = select id, name, email, (0 ;
if (isset($category)){
$query .=  + category = $category ;
}
if (isset($experience)){
$query .=  + experience between $experience[0] and $experience[1] ;
}
if (isset($location)){
$query .=  + location = '$location' ;
}
if (isset($skills)){
$query .=  + count(skills.id) ;
}
$query .= ) as score ;
$query .=  from programmer, programmer_skill ;
$query .=  where programmer.programmer_id = programmer_skill.programmer_id
;
$query .=and score  0 ;
$query .=  order by score desc ;

--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]