<?php

include("config.php");
if(isset($_POST['input'])){
    
    $input= $_POST['input'];
    $query= "SELECT* FROM maps 
    WHERE LayoutName LIKE '{$input}%'
    OR LongLink LIKE '{$input}%'
    OR Sharestring LIKE '{$input}%'
    OR ShortLink LIKE '{$input}%'
     OR Creator LIKE '{$input}%'
     OR mapType LIKE '{$input}%'
    OR WaLa LIKE '{$input}%'
    LIMIT 5";
    $result= mysqli_query($con, $query);
    
    if(mysqli_num_rows($result)>0){?>
    <table class="table table-bordered table-striped mt-4">
        <thead>
            <tr>
                <td>Layout Name</td>
                <td>Short Link</td>
                <td>Long Link</td>
                <td>Sharestring</td>
                <td>Author</td>
                <td>Water or Land</td>
                <td>Offense or Defense</td>
                
            </tr>
        </thead>
        <tbody>
            <?php
            while ($row=mysqli_fetch_assoc($result)){
                
                $layout = $row['LayoutName'];
                $shortlink = $row['ShortLink'];
                $longlink = $row['LongLink'];
                $sharestring = $row['Sharestring'];
                $creator = $row['Creator'];
                $wala = $row['WaLa'];
                $mapType = $row['mapType'];
                    
              ?>
            <tr>
                <td><?php echo $layout;?></td>
                <td><?php echo $shortlink;?></td>
                <td><?php echo $longlink;?></td>
                <td><?php echo $sharestring;?></td>
                <td><?php echo $creator;?></td>
                <td><?php echo $wala;?></td>
                <td><?php echo $mapType;?></td>
            </tr>
                <?php
            }
            ?>
        </tbody>
    </table>
     <?php   
        
    }else{
        echo "<h6 class='text-danger text-center mt-3'>Sorry, But I could'nt find any maps associated with that search</h6>";
    }
    
}
 $mysqli -> close();
?>