"destruk" wrote:
If you are using a server, send the search term to a script on the server and have the server return matches.
If you're doing this on the end user device, you would need to loop through the content list and run your matches on the keys for the content like title, description, actors, etc. Any match found would be copied into a results string, or copied into a result content set for display.
searchresults=[]
For x=0 To m.masterlist.count()-1
For y=0 To m.masterlist[x].count()-1 'search current category
If Len(FinalSearchTerm)=1
'search titles that begin with that character and skip other fields
If LCASE(m.masterlist[x][y].Title.Left(1))=LCASE(FinalSearchTerm)
oktoadd=1
For z=0 To searchresults.count()-1
If searchresults[z].contentID=m.masterlist[x][y].contentID
oktoadd=0
Exit For
End If
Next
If oktoadd=1 searchresults.push(m.masterlist[x][y])
End If
Else
If(Instr(1,LCASE(m.masterlist[x][y].Title),LCASE(FinalSearchTerm))>0) or (Instr(1,LCASE(m.masterlist[x][y].Director),LCASE(FinalSearchTerm))>0) or (Instr(1,LCASE(m.masterlist[x][y].Actors[0]),LCASE(FinalSearchTerm))>0) or (Instr(1,LCASE(m.masterlist[x][y].Actors[1]),LCASE(FinalSearchTerm))>0) or (Instr(1,LCASE(m.masterlist[x][y].Actors[2]),LCASE(FinalSearchTerm))>0) or (Instr(1,LCASE(m.masterlist[x][y].Description),LCASE(FinalSearchTerm))>0) or (Instr(1,m.masterlist[x][y].ReleaseDate,FinalSearchTerm)>0)
oktoadd=1
For z=0 To searchresults.count()-1
If searchresults[z].contentID=m.masterlist[x][y].contentID
oktoadd=0
Exit For
End If
Next
If oktoadd=1 searchresults.push(m.masterlist[x][y])
End If
End If
Next
Next
If searchresults.count()>1 'only sort titles if there is more than 1 match
'sort results by title alphabetical
titles=[]
contentids=[]
For x=0 To searchresults.count()-1
titles.push(LCASE(searchresults[x].title+"**********"+searchresults[x].contentid))
Next
Sort(titles) 'alphabetize
searchresults2=[]
For T=0 To titles.count()-1 'initial count of sorted results array
For X=0 To searchresults.count()-1
svt=Instr(1,titles[T],"**********")
If LCASE(Mid(titles[T],(svt+10)))=LCASE(searchresults[X].contentid)
searchresults2.Push(searchresults[X])
Exit For
End If
Next
Next
SearchResults=searchresults2
End If
If SearchResults.Count()>0
result=ShowResults(FinalSearchTerm,SearchResults) 'This sends the search term used as well as the content list that was found to another routine to display the results
If result=9999 Return 9999
Else
ShowErrorDialog("There were no videos found.","")
End If
<?php
include 'includevars.php';
//this file is only utilized by Roku Interface on back end of server using a GET request.
if ($_SERVER["REQUEST_METHOD"] == "GET")
{
$con=@new mysqli($sitename,$masteraccessname,$masteraccesspw,$databasename);
if (mysqli_connect_errno())
{
exit("Unable to connect to database.");
}
// read the post from ROKU
$value2 = urldecode(stripslashes($_GET["Term"])); //search term
if($value2=="")
{
$_xml="<?xml version=\"1.0\" encoding=\"UTF-8\"?>".chr(13);
$_xml.="<feed>".chr(13);
$_xml.="<item>".chr(13);
$_xml.="<thumbnail>".$rootdir."Empty.jpg</thumbnail>".chr(13);
$_xml.="<title>Placeholder</title>".chr(13);
$_xml.="<streamUrl>".$baseserverip."Empty.mp4</streamUrl>".chr(13);
$_xml.="</item>".chr(13);
$_xml.="</feed>".chr(13);
echo $_xml;
exit();
}
if (strlen($value2)>2)
{
$sql="SELECT * FROM ".$maindbname." WHERE title LIKE '%".$value2."%' OR description LIKE '%".$value2."%' ORDER BY title"; //Do search query
}
else
{
$sql="SELECT * FROM ".$maindbname." WHERE title LIKE '".$value2."%' ORDER BY title"; //Do search query based on first letters of filename
}
$res=mysqli_query($con, $sql)
or die("Error: ".mysqli_error($con));
if (mysqli_num_rows($res)==0) //no shows
{
$_xml="<?xml version=\"1.0\" encoding=\"UTF-8\"?>".chr(13);
$_xml.="<feed>".chr(13);
$_xml.="<item>".chr(13);
$_xml.="<thumbnail>".$rootdir."Empty.jpg</thumbnail>".chr(13);
$_xml.="<title>Placeholder</title>".chr(13);
$_xml.="<streamUrl>".$baseserverip."Empty.mp4</streamUrl>".chr(13);
$_xml.="</item>".chr(13);
$_xml.="</feed>".chr(13);
echo $_xml;
}
else
{
$mx=0;
while ($info=mysqli_fetch_array($res,MYSQLI_NUM))
{
$title[$mx]=$info[0]; //title
$thumbnail[$mx]=$info[1]; //thumbnail
$streamurl[$mx]=$info[2]; //streamurl
$mx++;
}
$_xml="<?xml version=\"1.0\" encoding=\"UTF-8\"?>".chr(13);
$_xml.="<feed>".chr(13);
For ($i=0;$i<$mx;$i++)
{
$_xml.="<item>".chr(13);
$_xml.="<title>".$title[$i]."</title>".chr(13);
$_xml.="<thumbnail>".$thumbnail[$i]."</thumbnail>".chr(13);
$_xml.="<streamUrl>".$streamurl[$i]."</streamUrl>".chr(13);
$_xml.="</item>".chr(13);
}
$_xml.="</feed>".chr(13);
echo $_xml;
}
mysqli_close($con);
}
?>