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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:24:48+00:00 2026-06-15T11:24:48+00:00

I want to build a form to change the data in MySQL table. Firstly,

  • 0

I want to build a form to change the data in MySQL table. Firstly, I list all the data in the adminindex.php page. Then, I create a button to open the selected data in a form. I’ve done assigning the form fields to the main (pk) MySQL table. My problem started there when I need to fetch the foreign table data as the table contains many foreign data. As you guys know, a class may have many students, I have created the fields for class data, now the problem is in students data. Do I have to create many fields to fetch the data from MySQL foreign tables? If yes, could you guys guid me the code steps ? Thank you very much. Really appreciate your help 😀

These are my steps:

Firstly I echo the rows, then I codes the form actions. Then, in adminpost.php, I create variables, link the fields and use UPDATE MYSQL to update the data in tables. I’ve succeeded in updating the primary table data but I’m stuck in foreign key data. Thanks 😀

  • 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-15T11:24:49+00:00Added an answer on June 15, 2026 at 11:24 am

    Have 2 pages. Display data in a form in first one and have update in the second. Here is a code for doing it one by one, you can build on it for multiple rows at a time if you want to.

    edit.php

    <?php
    mysql_connect('ip', 'username', 'password') or die(mysql_error());
    mysql_select_db("db_name") or die(mysql_error());
    
    $query = mysql_query("SELECT * FROM table1 where order by question_id limit 1") or             die(mysql_error());
    
    if(mysql_num_rows($query)>=1){
    while($row = mysql_fetch_array($query)) {
        $id = $row['id'];
        $value1= $row['value1'];
        $value2= $row['value2'];
    }
    ?>
    <form action="update.php" method="post">
    <input type="hidden" name="ID" value="<?php echo $id;?>">
    
    Value1: <input type="text" name="value1" value="<?php echo $value1;?>">
    <br>
    Value2: <input type="text" name="value2" value="<?php echo $value2?>">
    <input type="Submit" value="Change">
    </form>
    <?php
    }else{
        echo 'No entry found. <a href="javascript:history.back()">Go back</a>';
    }
    ?>
    

    update.php

     <?php
     mysql_connect('ip', 'username', 'password') or die(mysql_error());
     mysql_select_db("db_name") or die(mysql_error());
    
     $id = mysql_real_escape_string($_POST["ID"]);
     $value1 = mysql_real_escape_string($_POST["value1"]);
     $value2 = mysql_real_escape_string($_POST["value2"]);
    
     $query="UPDATE table1 SET value1 = '.$value1.', value2 = '.$value2.' WHERE id='$id'";
    
    
     mysql_query($query)or die(mysql_error());
     if(mysql_affected_rows()>=1){
    echo "<p>($id) Record Updated<p>";
     }else{
    echo "<p>($id) Not Updated<p>";
     }
     ?>
     <a href="edit.php">Next</a>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a newcomer to Rails. I want to build a simple form that determines
I want to build a python program that deletes all the photos from my
I want to create a comment form at the bottom of a blog entry.
I want to build a login form that displays in a sidebar across every
Just wondering which is best here. I want to output data from a table
I want to create a form using some fields from multiple entities. I have
I'm designing a form-building interface. All available fields will be in an unordered list
I want to build a search form in a .net desktop application which is
I'm want to build an application in VC++ 2008 (Windows form application). Here I
I want a simple filter form, and a table below it. When the user

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.