Q:

Change div style after search form

I want to develop a simple website, It consists of a search form (text input and submit button) which are used to fetch data from a database. Under the form, i make some "map" using div tag that each of div tag represent location. If data was found, one of the div tag that represent the location of we've search before will change the style background-color.
here is my html
<html>
<head>
    <title></title>
</head>
<body>
    <div>
        <form name='searhThings' method=GET action='<?php $_SERVER['PHP_SELF']; ?>' />
            <input type='text' name='idX' />
            <input type='submit' value='search' /> 
        </form>
    </div>
    <div>
        <p>Location: 
        <?php
            include 'connection.php';

            if ((isset($_GET['submit'])) AND ($_GET['search'] <> "")) {  
                $data = $_GET['search'];

                $result = mysql_query("SELECT * FROM things WHERE ID_X = '$data'");
                $row = mysql_fetch_array($result);
                if ($row) {
                    # code...
                    $id_location = $row['LOCATION'];
                    echo $id_location;
                } else {
                    # code...
                    echo "data not found";
                }
            }
        ?>
        </p>
    </div>
    <div>
        <div id='locationA'></div>
        <div id='locationB'></div>
        <div id='locationC'></div>
        <div id='locationD'></div>
        <div id='locationE'></div>
    </div>
</body>
</html>

My question is what should i use to implement this?

A:

You can keep a class as active in the  location div based on the condition

Location: 
        

        if ((isset($_GET['submit'])) AND ($_GET['search'] <> "")) {  
            $data = $_GET['search'];

            $result = mysql_query("SELECT * FROM things WHERE ID_X = '$data'");
            $row = mysql_fetch_array($result);
            if ($row) {
                # code...
                $id_location = $row['LOCATION'];
                echo $id_location;
            } else {
                # code...
                echo "data not found";
            }
        }
    ?>
    </p>
</div>
<div>
    <div id='locationA' class="<?php if($locationA){ echo 'active'; }?>"></div>
    <div id='locationB' class="<?php if($locationB){ echo 'active'; }?>"></div>
    <div id='locationC' class="<?php if($locationC){ echo 'active'; }?>"></div>
    <div id='locationD' class="<?php if($locationD){ echo 'active'; }?>"></div>
    <div id='locationE' class="<?php if($locationE){ echo 'active'; }?>"></div>
</div>

where $locationA,$locationB,$locationC,$locationD,$locationE are the variables you have to assign Boolean value if it found.

