I have a form that displays candidates with their details using a mysql while loop and below each candidate is a "vote" button which is also inside the loop. I need to add 1count to a record when their button is clicked. My problem is the buttons inside the loop has the same names so they are all affected with the update even if only one is clicked.

```
if ($conn->connect_error) {
                die("Connection failed: " . $conn->connect_error);
            } 

                $sql = "SELECT ename FROM election_title ORDER BY `sdate` ASC";
                $result = $conn->query($sql);
                if ($result->num_rows > 0) {
            while($row = $result->fetch_assoc()) {
                $ename= $row['ename'];
        ?> 
            <p><font size= "6px" align = "center" color = "#efbf77"> <?php echo $row['ename']. "<br>";?></p>
        <?php

            $sql = "SELECT * FROM candidate_list T1 INNER JOIN election_title T2 ON T1.ename = T2.ename WHERE T1.ename LIKE '%$row[ename]%';";
            $res = $conn->query($sql);
            if ($res->num_rows > 0) {
                while($rowval = $res->fetch_assoc())  {
                    $id= $rowval['id'];
                    $image_content= $rowval['image_content'];
                    $ename= $rowval['ename'];
                    $pos= $rowval['pos'];
                    $fname= $rowval['fname'];
                    $mname= $rowval['mname'];
                    $lname= $rowval['lname'];

        ?> 

                <div class = "cand">
                <?php echo '<img src="data:image/jpeg;base64,' . base64_encode( $rowval['image_content'] ) . '" width = "100%" height = "auto" />';?><?php echo "<p class = 'bold'>" .$rowval['fname']. " " .$rowval['mname']. " " .$rowval['lname'] . "</p>" .$rowval['pos']. "<br/>" .$rowval['pname'];?>
                 <form action="castvote.php" method="post">
                 <INPUT TYPE=submit NAME="<?php echo $fname; ?>" VALUE="<?php echo 'Vote ' .$fname; ?>">
                </div>
        <?php
        }
            } else {
            echo "No candidate(s) listed.";
        }

        ?>
        <?php
        }
            } else {
            echo "0 results";
        }
        ?>

```

And this is my query.

```
<html>
<head>
    <title>NSDCI Voting System</title>
    <link rel="stylesheet" href="css/style.css">
</head>
    <?php
        $host = 'localhost';
        $user = 'root';
        $pass = '';
        $db = 'voting_system';

        $fname = $_POST['fname'];
        $con = mysqli_connect($host, $user, $pass, $db);
        if($con)
        {

        $sql = "UPDATE candidate_list SET votes = votes +1 WHERE fname = $fname";
        $query = mysqli_query($con, $sql);

        if($query)
        echo 'data inserted succesfully';
        }

            echo 'connected succesfully to the db!';

    ?>

```

How can i query a WHERE clause that matches my button name. Thanks in advance