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 8228427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:27:10+00:00 2026-06-07T16:27:10+00:00

I want to show the selected ID data in the form and EDIT it

  • 0

I want to show the selected ID data in the form and EDIT it and UPDATE in the database. I selected the data from the database and put it in the input tag but it doesn’t work. Please help!

<html>
<body>
<?
$db = mysql_connect("localhost", "root","");
mysql_select_db("db_ncs",$db);
$id = $_GET['s_id'];
if($id)
{
    $result=mysql_query("SELECT * FROM tbl_student WHERE s_id=$id");
    $row = mysql_fetch_assoc($result);
}
?>

<form method="post" action="update.php">
    Name:<input type="Text" name="name" value="<?php echo $row['s_name'];?>" /><br>
    Contact:<input type="Text" name="contact" value="<?php echo $row['s_contact'];?>" /><br>
    Address:<input type="Text" name="address" value="<?php echo $row['s_address'];?>" /><br>
    E-mail:<input type="Text" name="email" value="<?php echo $row['s_email'];?>" /><br>
    <input type="submit" name="update" value="Update">
</form>

<?
if(isset($_POST['update']))
    {
    $name = $_POST['s_name'];
    $contact = $_POST['s_contact'];
    $address = $_POST['s_address'];
    $email = $_POST['s_email'];
    $sql = "UPDATE tbl_student
            SET (s_name='$name', s_contact='$contact', s_address='$address', s_email='$email')
            WHERE s_id=$id";
    $res = mysql_query($sql);       
    if($res)
        {
            echo "Upadate Successfull!";
        }
        else
        {
            echo "Sorry!";
        }
    }

?>

</body>
</html>
  • 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-06-07T16:27:12+00:00Added an answer on June 7, 2026 at 4:27 pm

    You forgot to pass the id.

    Add this between the <form> tags.

    <input type="hidden" name="s_id" value="<?php echo $id;?>" />
    

    You also need to make your methods consistent. The form submits the data via method="get" but you ask for it via $_POST. You also need to make the input names consistent with the names you ask for, by either adding or removing the “s_” in the appropriate places.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to build an algorithm to search and filter data from my database.
I want to show a border type look for an element but without using
I want to show my groupview with 2 lines to down direction, but only
I have a scenario where I want to show hierarchical data in a DataGrid
Using jQuery/jQueryUI I want to populate a form using this HTML/JS show below. The
I am fetching data from database and i am showing it in multiple select
I'm using Jquery and Ajax function to get data from MySql and put it
I want to return JSON data from a resulted SQL statement in a PHP
I want show an information page after success db opartions. And after the info
I want show annotation view (above one of my pin) after load map. For

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.