在php中设置动态选择下拉列表的默认值

I have a form in an edititem.php page that is used to edit an item. The idea is that from another page, the searchitem.php a user can click edit and is taken to the edititem.php page to edit the selected item. What I'm trying to do is that automatically the default values in the form elements are populated with the values of the item selected to edit (from the searchitem.php) so that the user finds the form populated and only needs to modify the necessary value/s. I'm passing all the required variables to the edititem.php and I am able to poulate all the input tags but I have a problem with the select tag which is not being set with the desired value. The select tag is being populated dynamically from a mysql database.

           <label>Category:</label>
            <select name="category">
            <?php
                    $selectedCategory = ''; 
                    if (isset($_POST['category'])) {
                        $selectedCategory = $_POST['category']; 
                    }
                    $sql_cat = "SELECT id, description FROM category ORDER BY description ASC";
                    $result_cat = mysqli_query($connection, $sql_cat);

                    if(mysqli_num_rows($result_cat) > 0){
                        while($row = mysqli_fetch_assoc($result_cat)){
                            $selected = '';
                            if ($selectedCategory == $row['id']) {
                                $selected = 'selected';   
                            }
                           echo '<option value="' . htmlspecialchars($row['id']) . '" '.$selected.'>' 
                           . htmlspecialchars($row['description']) 
                           . '</option>';
                        }  
                    }
                ?>  

With the above code the items in the select tag are being populated dynamically from a table and also if the page is refreshed the selected item is maintained as the selected value.

However I cannot set the default value when I press the edit item from the searchitem.php. The last value in the table is being displayed as default. Any ideas how I can achieve this since I cannot figure out how to do it. Note that all the variables are being passed successfully to the edititem.php page I just need to set the default value of the select drop down list as per the passed variable while keeping the select drop down list dynamic.