php how can I make my search engine search for mutiple keywords?

this is what I have so far:

<?php
include "config.php";
if (@$_POST['search']=="search")
{
$keyword=$_POST['keyword'];
$result=mysql_query("SELECT * FROM listed WHERE `itemname` LIKE ‘%$keyword%’ OR `message1` LIKE ‘%$keyword%’");
while ($results = mysql_fetch_array($result))
{
$tag=$results['tag'];
$idno=$results['id'];
$title=$results['name'];
$description=$results['message1'];
$position=40;

$post = substr($description, 0, $position);

echo "<b>$tag,$title,$post,$idno</b>
?>

I also heard of adding a thing called noslashes or something which is supposed to prevent unwanted SQL queries. Any info on that?

Technorati Tags: , , ,

Write a C++ searching program that declares an array matrix of type integer that prompts the user to input N n?

Write a C++ searching program that declares an array matrix of type integer that prompts the
user to input N numbers. Again prompt the user to input the number to be searched. If the
number can be found, print its position, otherwise print “ It is not in the list”.

Technorati Tags: , ,

?php How would I implement “preg_replace” into my simple search engine?

Here is what I have so far….

if (@$_POST['search']=="search")
{
@$keywords=split(" ",$_POST['keyword']);

foreach ($keywords As $keyword){

$keyword = get_magic_quotes_gpc() ? addslashes(trim($keyword)) : trim($keyword);

$search[]="itemname LIKE ‘%$keyword%’ OR message1 LIKE ‘%$keyword%’";

}

$search = join("OR ", $search);

$result=mysql_query("SELECT * FROM listed WHERE($search)");
while ($results = mysql_fetch_array($result))
{
$price=$results['price'];
$idno=$results['id'];
$title=$results['itemname'];
$description = $results['message1'];
$position=40;

$post = substr($description, 0, $position);

echo //the rest of the code won’t fit but this is where I echo my results…which works fine.

My search query is having a problem with searches containing symbols, such as ?,."!@#$%^&* I was wondering how I can filter these out using the preg_replace function.

My PHP is very minimal, so over-explaining your answers is greatly appreciated.

Technorati Tags: , , , , ,

I have a Peg Solitaire program in AI. To implment Depth First Search, how do I convert an Array to Tree?

Its an Artificial Intelligence Programming assignment to implement Peg Solitaire with pegs placed in various places (without filling whole board)

Need to implement Depth and Breadth First Search to find solutions to the PEG solitaire Game.

How Do I convert an array of Peg Positions into a Tree to implement the DFS and BFS. I am unable to decide which will be Root Node for the implementation:(

Technorati Tags: , , , , , , , , , ,

Can Somone Please Fix This Code? Its a C++ Linear Search Program?

PLease tell me y this program will not compile. I tried it and the only thing that is causing trouble is the last line…… the cout line. the program compiles when i take out the << lsposition << part but the it dosen’t display the place the integer is in.
Please Help If You Can….

Here is the code… and don’t worry about iostream or namespace, thats not the problem…

//Exercise Five Linear Search
cout << "\n\n\n…..Linear Search…..\n\n";
//Program lists numbers and asks user to enter a number. Program searches for positions number
//sets base array
int lsarray[17] = {7,3,32,2,55,34,6,13,29,22,11,9,1,5,42,39,8};////// (X)
//lists nmbers in array
cout << "List: 7, 3, 32, 2, 55, 34, 6, 13, 29, 22, 11, 9, 1, 5, 42, 39, 8";
//sets value int
int lsvalue = 0;////////// (#)
//gets value ( number searching for )
cout << "\nEnter An Integer In The List To Search For: ";
cin >> lsvalue;////////// (#)
//sets position int in a for code
for (int lsposition = 0; lsposition <= lsvalue; lsposition++)///////(I)
{
if (lsarray[lsposition] == lsvalue)
break;
else
continue;
}
cout << "\nItem Found At Index [" << lsposition << "]";

please don’t write a new code and just use what i have.
Thanks in advance

Technorati Tags: , , , , , , , , , , ,

. If in insertion sort we use binary search to identify the position, the worst case running time will?

3.The usual O(n2) implementation of Insertion sort to sort an array uses linear search to identify the position where an element is to be inserted into already sorted part of the array. If, instead, we use binary search to identify the position, the worst case running time will
a.remain O(n2)
b.become O(n(log n) 2)
c.become O(n log n)
d.become O(n)

Technorati Tags: , , , , , , ,