<?php
require_once('includes/load.php');

if (isset($_GET['search_query']) && !empty($_GET['search_query'])) {
    $search_query = $_GET['search_query'];
    $search_option = $_GET['search_option'];

    $data = get_all_data_with_search($search_query, $search_option);

    if ($data === false) {
        echo "Invalid search option.";
    } else if (empty($data)) {
        echo "No results found.";
    } else {
        // Display search results
        foreach ($data as $data) {
            // Output the results as needed
            echo "Part Number: " . $data['part_number'] . "<br>";
            echo "Description: " . $data['description'] . "<br>";
            echo "Color: " . $data['color'] . "<br>";
            echo "Unit Price: " . $data['unit_price'] . "<br>";
            echo "Unit Measurements: " . $data['unit_measurements'] . "<br>";
            echo "<hr>";
        }
    }
} else {
    echo "Invalid search query.";
}
?>
