Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7652531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:47:42+00:00 2026-05-31T11:47:42+00:00

I have an Task creation – View – Edit page. Once I create the

  • 0

I have an Task creation – View – Edit page. Once I create the task and user wants to edit it. He clicks edit button. So the value gets populated according to id. All the value gets populated except for Dropdown.:

This are my dropdowns :

<b>Assignee: &nbsp &nbsp &nbsp &nbsp </b><select name = "assignee" value = <?php echo $assignee ?></select>
<b>Priority:</b><select name = "priority" value= "<?php echo $priority; ?>" id="priority"><option>Low</option><option>Medium </option><option>High</option></select>
<b>Status: </b><select name = "status" value= "<?php echo $status; ?>" ><option>Assigned</option><option>Yet to Start </option><option>In Progress</option><option>Completed</option><option>Blocked</option></select>

This is code for getting the values and showing in table and updating to database

<?PHP
function renderForm($id, $task, $comments, $assignee, $priority, $status, $dataum1, $dataum2, $error) {/connecttothedatabaseinclude ('configdb1.php');
    // check if the form has been submitted. If it has, process the form and save it to the database
    if (isset($_POST['submit'])) {
        // confirm that the 'id' value is a valid integer before getting the form data
        if (is_numeric($_POST['id'])) {
            // get form data, making sure it is valid
            $id = $_POST['id'];
            $task = $_POST['task'];
            $comments = $_POST['comments'];
            $assignee = $_POST['assignee'];
            $priority = $_POST['priority'];
            $status = $_POST['status'];
            $dataum1 = $_POST['dataum1'];
            $dataum2 = $_POST['dataum2'];
            // check that firstname/lastname fields are both filled in
            if ($task == '' || $comments == '') {
                // generate error message
                $error = 'ERROR: Please fill in all required fields!';
                //error, display form
                renderForm($id, $task, $comments, $assignee, $priority, $status, $dataum1, $dataum2, $error);
            } else {
                // save the data to the database
                mysql_query("UPDATE work SET task='$task', comments='$comments', assignee='$assignee', priority='$priority', status='$status', dataum1='$dataum1', dataum2='$dataum2' WHERE id='$id' ") or die(mysql_error());
                // once saved, redirect back to the view page
                header("Location: view.php");
            }
        } else {
            // if the 'id' isn't valid, display an error
            echo 'Error!';
        }
    } else
    // if the form hasn't been submitted, get the data from the db and display the form
    {
        // get the 'id' value from the URL (if it exists), making sure that it is valid (checing that it is numeric/larger than 0)
        if (isset($_GET['id']) && is_numeric($_GET['id']) && $_GET['id'] > 0) {
            // query db
            $id = $_GET['id'];
            $result = mysql_query("SELECT * FROM work WHERE id=$id") or die(mysql_error());
            $row = mysql_fetch_array($result);
            // check that the 'id' matches up with a row in the databse
            if ($row) {
                // get data from db
                // get data from db
                $task = $row['assignee'];
                $comments = $row['2'];
                $assignee = $row['assignee'];
                $priority = $row['priority'];
                $status = $row['status'];
                $dataum1 = $row['dataum1'];
                $dataum2 = $row['dataum2'];
                // show form
                renderForm($id, $task, $comments, $assignee, $priority, $status, $dataum1, $dataum2, '');
            } else
            // if no match, display result
            {
                echo "No results!";
            }
        } else
        // if the 'id' in the URL isn't valid, or if there is no 'id' value, display an error
        {
            echo 'Error!';
        }
    }
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T11:47:43+00:00Added an answer on May 31, 2026 at 11:47 am

    The select element does not have a value attribute – the selected option has a selected attribute.

    In other words, you want something like:

    <select name = "priority" id="priority">
        <option <?php if ($priority == 'Low') { echo 'selected="selected"'; } ?>>Low</option>
        <option <?php if ($priority == 'Medium') { echo 'selected="selected"'; } ?>>Medium </option>
        <option <?php if ($priority == 'High') { echo 'selected="selected"'; } ?>>High</option>
    </select>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a task to show digital clock (with minutes precision) on HTML page
Using Script Task, I have written a code to create a folder and create
I have a workflow that creates a new task at the time of creation
Background I have a web app that will create an image from user input.
I am new this sharepoint development and i have task in hand to do
I have this Task model: class Task < ActiveRecord::Base acts_as_tree :order => 'sort_order' end
I have a task and I want to generate some code using the CodeDom.
I have a Task object that has a collection of Label objects ... in
I have a task of parsing a simple XML-formatted string in a MySQL stored
I have a task to make a survey to be displayed in SharePoint 2007

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.