Help with getting the Search Form to search within subcategory

Thanks for all the previous help.
The web video script that I’m modifying successfully filters videos into categories and subcategories. I’ve added this Search Form which appears on subcategory results pages:

if (preg_match('#/?sub__(\d)+\b#',$_SERVER['REQUEST_URI'],$matches)) {
echo "<form action='#' method='GET' id='subcategory'>
<input id='search' name='keywords' type='text' placeholder='Search--SubCategory'>
<input type='submit' value='Search' />
<input type='hidden' id='subcategory' name='subcategory_id' value='{$matches[1]}'>

I’ve also added the following code to the same page in an attempt to get the Search Form to have the functionality of searching just within the currently displayed subcategory page(s) results, for title, description and/or tags(keywords), and display those results:

$data = array('status' => 400);
if (!empty($_POST['search_value'])) {
$search_value = PT_Secure($_POST['subcategory']);
$search_result = $db->rawQuery("SELECT * FROM " . T_VIDEOS . " WHERE (title '%$search_value%' OR tags '%$search_value%' OR description '%$search_value%') AND sub_category = '%$search_value%' ");
if (!empty($search_result)) {
$html = '';
foreach ($search_result as $key => $search) {
$search = PT_GetVideoByID($search, 0, 0, 0);
$html .= "<div class='search-result'><a href='$search->url'>$search->sub_category</a></div>";
$data = array('status' => 200, 'html' => $html);

but no success yet. The T_VIDEOS (videos table) looks like this (attached).
Any guidance with this is appreciated

Sponsor our Newsletter | Privacy Policy | Terms of Service