if ($page < 1) {
    $page = 1;
}
if (empty($page)) {
    $page = 1;
}
$limit = getPaginationLimit();
if ($limit == 0) {
    $limit = 3;
}
//echo $sql;
$sql_qr = dopaging($sql, '', $limit);
$result = mysql_query($sql_qr) or die(mysql_error());
$sql_qr = doAjaxpaging($sql, $page, $limit);
$result = mysql_query($sql_qr) or die(mysql_error());
$catlist = makeSearhList(0, 0);
/*display the active template*/
$active_template = displayTemplate();
$CartRowCount = mysql_num_rows($result);
$prodimagedir = SITE_URL . "/products/";
?>
<div id="searchlisting">
    <?php 
include "includes/htmltop.php";
/* Top File Name */
include_once "includes/" . $active_template[0];
?>
    <script language="javascript"   type="text/javascript"  src="<?php 
echo SITE_URL;
?>
/js/jquery.js"></script>
function makeSearhList($current_cat_id, $count)
{
    global $tableprefix;
    static $option_results;
    if (!isset($current_cat_id)) {
        $current_cat_id = 0;
    }
    $count = $count + 1;
    $productRow = array();
    $sql = "SELECT category_id as id, category_name as name\n\t\t    FROM " . $tableprefix . "categories WHERE parent_id = '" . addslashes($current_cat_id) . "' ORDER BY name ASC ";
    $get_options = mysql_query($sql);
    $num_options = mysql_num_rows($get_options);
    if (mysql_num_rows($get_options) != 0) {
        while ($row = mysql_fetch_assoc($get_options)) {
            $productRow[] = $row;
        }
    }
    if ($current_cat_id == '2') {
        $MadeToOrder = getMadeToOrderCatgeoryItemsCheck($current_cat_id);
        if ($MadeToOrder != '') {
            $madetoorder[] = array('id' => '', 'name' => $MadeToOrder);
            $newArray = array_merge($productRow, $madetoorder);
        }
    } else {
        $newArray = $productRow;
    }
    $CategoryArray = array();
    foreach ($newArray as $key => $row) {
        $CategoryArray[$key] = $row['name'];
    }
    @array_multisort($CategoryArray, SORT_ASC, $newArray);
    if (count($newArray) > 0) {
        foreach ($newArray as $catRow) {
            $cat_id = $catRow['id'];
            $cat_name = $catRow['name'];
            /*-------Multicart 2.0 Upgradation------------*/
            if ($cat_id != '') {
                $result_product1 = checkProductExistChk($cat_id);
                $resultRows = mysql_num_rows($result_product1);
                if ($resultRows > 0) {
                    if ($current_cat_id != 0) {
                        $indent_flag = "--";
                        for ($x = 2; $x <= $count; $x++) {
                            $indent_flag .= " --> ";
                        }
                    }
                    $cat_name = $indent_flag . stripslashes($cat_name);
                    $option_results[$cat_id] = stripslashes($cat_name);
                    makeSearhList($cat_id, $count);
                }
            }
            if ($cat_name == 'Made To Order') {
                $cat_name = $indent_flag . stripslashes($cat_name);
                $option_results['made-to-order'] = stripslashes($cat_name);
            }
        }
    }
    return $option_results;
}