Help needed in searching a sentence in the code

Help needed in searching a sentence in the code

am 26.05.2010 16:20:31 von Nagendra Prasad

--000e0cd13bba2b825304877ffb03
Content-Type: text/plain; charset=ISO-8859-1

Hi All,

I have this code where user can search a song or the entire song title. It
looks like when a user search a single word its searching and giving the
proper results. However if the user wants to search the entire sentence its
not giving the proper results. For example let say I have searched for the
MJ's song "Earth Song", its giving me the proper results. However if I am
searching for the MJ's " Why You Wanna Trip On Me", its not giving me the
proper results. Below is the code:





//get data
$button = $_GET['submit'];
$search = $_GET['search'];

$s = 0;
$s = $_GET['s'];
if (!$s)
$s = 0;
$i = 0;

$e = 30; // Just change to how many results you want per page


$next = $s + $e;
$prev = $s - $e;




if (strlen($search)<=2)


echo "

face='sana-serif' size='6'>MP3dom size='3'>
method='GET'> value='$search'> value='Search'>
width='100%' height='1px'>
width='100%' height='10px'>
Must be greater
then 3 chars

";
else
{
echo "

size='6'> style='text-decoration: none'>MP3dom face='sana-serif' size='3'> action='search.php' method='GET'> size='50' name='search' value='$search'> value='Search'>
";

//connect to database
mysql_connect("localhost","root","");
mysql_select_db("mp3");



//explode out search term
$search_exploded = explode(" ",$search);

foreach($search_exploded as $search_each)
{

//construct query
$x++;
if ($x==1)
$construct .= "name LIKE '%$search_each%'";
else
$construct .= " OR name LIKE '%$search_each%'";

}

//echo outconstruct
$constructx = "SELECT * FROM data WHERE $construct";

$construct = "SELECT * FROM data WHERE $construct LIMIT $s,$e ";
$run = mysql_query($constructx);

$foundnum = mysql_num_rows($run);


$run_two = mysql_query("$construct");

if ($foundnum==0)
echo " />
align='right'>No results found for
$search

";
else
{
echo "

/>
align='right'>Showing 1-30 of $foundnum results found for
$search.

";







print '

align="center" >';
print '';

print '';
print '';
print '';
print '';

print '';
while ($runrows = mysql_fetch_assoc($run_two))
{
//get data
$type = $runrows['artist'];
$date = $runrows['date'];
$name = $runrows['name'];
$size = $runrows['size'];



foreach ($runrows as $row)
{
if ($i % 2 != 0) # An odd row
$rowColor = "#EBECE4";
else # An even row
$rowColor = "#FEF1E9";



print '
ArtistSong
Name
Movie
Date
Size
';

}


print '';
print '';

print '';
//print '';

print '';


print '';
print '';
print '';
print '';
print '';



print '
'.' size=2>'."$type".''.''." herf='$url'>$name".' '.' size=2>'."$name".' '.' size=2>'."$date ".''.''."$size
".'
'.''."$se
".'
'.''."$le
".'
';
print '';
print '';

}
?>











if (!$s<=0)
echo "";

$i =1;
for ($x=0;$x<$foundnum;$x=$x+$e)
{


echo " ";


$i++;


}

if ($s<$foundnum-$e)
echo "";

}
}


?>




************************************************************ ***************************************

Also, the above code is giving me the below errors:

*Notice*: Undefined index: s in *C:\wamp\www\searchengine\search.php* on
line *11
**Notice*: Undefined variable: x in *C:\wamp\www\searchengine\search.php* on
line *46*

*Notice*: Undefined variable: construct in *
C:\wamp\www\searchengine\search.php* on line *48


************************************************************ ******************************************************

Please help me with this.

Best,
Guru.

*

--000e0cd13bba2b825304877ffb03--