提交始终获取最后一个值

    <form action="" method="post">
<?php
    include 'Includes/database_connection.php';
    $sql = "select * FROM sims"     ;
    $result = mysql_query($sql,$con);       
    while($row = mysql_fetch_assoc($result)){
?>
        <ul class="category_list">
        <input type="hidden" value="$id1" name="hidden">
        <li><a href="#"><?php echo $row['phonenr'];?><input type="hidden" value="<?php echo $row['id'];?>" name="id"></a></li>

        </ul>

<?php
    }
?>
        <input type="submit" name="submit">
    </form>

So i got the above form where you can select phonenumbers and when you submit them a database should be updated. And there are 23 id's in it. After submitting the form it always takes the last value. What am i doing wrong?

if(@$_POST ['submit']) 
{  
    $id = $_POST["id"];
    echo $id;
    include 'Includes/database_connection.php';
    mysql_query("UPDATE pairings SET sim_id='$id' 
                            WHERE unit_id='$id1'")
}

Change your hidden field name to array like this

<input type="hidden" value="<?php echo $row['id'];?>" name="id[]">

then on PHP side use loop to retrieve

foreach ($_POST['id'] as $val) {
    $id = $val;
    include 'Includes/database_connection.php';
    mysql_query("UPDATE pairings SET sim_id='$id' 
                        WHERE unit_id='$id1'")
}

Slight modification specified by chandresh_cool, would get the result that you expect.

The input name is replaced with id, so the post key contains only the row[id], not the $_POST['id']

Instead change the name of the hidden field to accept as a array like this

<input type="hidden" value="<?php echo $row['id'];?>" name="id[]">

Then you can iterate id array as specified by chandresh_cool