<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css" integrity="sha384-gfdkjb5BdAXd+lj+gudLWI+BXq4IuLW5IT+brZEZsLFm++aCMlF1V92rMkPaX4PP" crossorigin="anonymous">
    <link rel="shortcut icon" type="image/x-icon" href="./favicon_io/favicon.ico">
    <link rel="stylesheet" href="style.css">
    <title>Modern Electronics | Query?</title>
</head>
<body>
    <header>
        <img src="./images/M.png" alt="logo">
        <nav>
            <a class="links" href="index.html">Home</a>
            <a class="links" href="products.html">Products</a>
            <!-- <a class="links about-me" href="about.html">About Us</a> -->
            <a class="links current" href="query.php">Query?</a>
        </nav>
        <div class="contact">
            <a class="links" href="mailto:"><i class="fas fa-solid fa-envelope"></i> modern.electr@gmail.com</a>
            <i class="fas fa-solid fa-phone"></i> 080-4132 0038</li>
        </div>
    </header>

    <div class="contact">
        <h2>Send in your query and we will get back to you!!!</h3>
        <br>
        
        <form id="form" METHOD="get">
            <label for="name">Name:</label>
            <input type="text" name="name" id="name"><br><br>
    
            <label for="company">Company Name:</label>
            <input type="text" name="company" id="company"><br><br>
            
            <label for="address">Address:</label>
            <input type="text" name="address" id="address"><br><br>
    
            <label for="mob-no">Contact Number:</label>
            <input type="number" name="mob-no" id="mob-no"><br><br>
    
            <label for="email">Email-ID:</label>
            <input type="email" name="email" id="email"><br><br>
    
            <label for="query">Query:</label><br>
            <textarea name="" id="" cols="50" rows="10"></textarea><br><br>
    
            <button>Submit</button><br>
        </form>
    </div>

<?php
    $conn=new mysqli("localhost","root","","modern-elec_contact");
    if ($conn->connect_error) {
        die("Connection Failed: ".$conn->connect_error);
    }

    if ($_GET) {
        $sql="INSERT INTO `queries`(NAME, COMPANY) VALUES ("."'".$_GET['name']."','".$_GET['company']."')";
        $result=$conn->query($sql);
        
        $sql="SELECT * FROM queries";
        $result=$conn->query($sql);
        
        ?>

    <div class="table">
        <table>
            <tr>
                <td>Name</td>
                <td>Company</td>
                <td>Status</td>
            </tr>

<?php
        if ($result->num_rows > 0) {
            while ($row=$result->fetch_assoc()) {
?>

<tr>
    <td><?php echo $row["NAME"]; ?></td>
    <td><?php echo $row["COMPANY"]; ?></td>
    <td><a href="query.php?<?php echo "delID=".$row["NAME"]; ?>"> <i class="fas-solid fa-trash"></i></a></td>
</tr>

<?php
	        } 
	    }
        
        else {
            echo "0 result";
        }

        if (isset($_GET['delID'])) {
            $sql="DELETE FROM `queries` WHERE NAME='".$_GET['delID']."';";
            $result=$conn->query($sql);
        }
    }
    $conn->close(); 
?>

        </table>
    </div>

    <iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d248839.05244870912!2d77.30278163281248!3d12.964800000000007!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x3bae15d890f91c45%3A0x55374acebe10e710!2sModern%20Electronics!5e0!3m2!1sen!2sin!4v1659258492069!5m2!1sen!2sin" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade" class="location"></iframe>

    <footer>
        <h4>All copyrights reserved. &copy;</h4>
        <br>
        <h2>Modern Electronics</h2>
        <br>
        <h3>D.M Lane, Bangalore, India</h3>
        <br>
        <h4><i class="fas fa-solid fa-phone"></i> 080-4132 0038</h4>
    </footer>
</body>
</html>
