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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:20:40+00:00 2026-05-25T19:20:40+00:00

I am trying to populate a text field with data from a MySQL database,

  • 0

I am trying to populate a text field with data from a MySQL database, but my code seems to not be working.

Any help would be greatly appreciated.

Heres the code:

<?php include ("../config.php");

// Connect to server and select database.
mysql_select_db($db, $con);

// get value of id that sent from address bar
$id = $_GET['ID'];


// Retrieve data from database
$sql="SELECT * FROM members WHERE id='$id'";
$result=mysql_query($sql);

echo '<form name="Edit" method="post" action="update.php">

<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td align="center"><strong>Name:</strong></td>
<td align="center"><strong>Contact:</strong></td>
<td align="center"><strong>Division:</strong></td>
<td align="center"><strong>Rank:</strong></td>
</tr>';
            while ($row = mysql_fetch_assoc($result))
            {
            //we will echo these into the proper fields

        echo '<tr>';
        echo '<td align="center"><input name="Name" type="text" id="Name" value="'; echo $row['Name']; echo '"></td>';
        echo '<td align="center"><input name="Contact" type="text" id="Contact" value="'; echo $row["Contact"]; echo'" size="15"></td>';
        echo'<td>
        <select name="Divison">
        <option value="L4D2">L4D2</option>
        <option value="CSS">CSS</option>
        <option value="GMOD">GMOD</option>
        <option value="TF2">TF2</option>
        </select>
        </td>
        <td>
        <select name="Rank">
        <option value="Division Leader">Division Leader</option>
        <option value="Admin">Administrator</option>
        <option value="Member">Member</option>
        </select>
        </td>
        </tr>';


echo '<tr>';
        echo '<td align="center"><input type="submit" name="Submit" value="Submit"></td>
        </tr>
</table>
</td>
</form>';
}
echo '
</tr>
</table>
</body>
</html>';


// close connection
mysql_close();

?>
  • 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-25T19:20:41+00:00Added an answer on May 25, 2026 at 7:20 pm

    edited my answer with full fixes:

    <?php include ("../config.php");
    
    // Connect to server and select database.
    mysql_select_db($db, $con);
    
    // get value of id that sent from address bar
    $id = $_GET['ID'];
    
    // Retrieve data from database
    $sql="SELECT * FROM members WHERE id='$id'";
    $result=mysql_query($sql);
    
    echo '<form name="Edit" method="post" action="update.php">
                <table width="400" border="0" cellspacing="1" cellpadding="0">
                    <tr>
                        <td align="center"><strong>Name:</strong></td>
                        <td align="center"><strong>Contact:</strong></td>
                        <td align="center"><strong>Division:</strong></td>
                        <td align="center"><strong>Rank:</strong></td>
                    </tr>';
    while ($row = mysql_fetch_assoc($result)) {
        //we will echo these into the proper fields
    
        echo '<tr>
                    <td align="center"><input name="Name" type="text" id="Name" value="'.$row['Name'].'"></td>
                    <td align="center"><input name="Contact" type="text" id="Contact" value="'.$row["Contact"].'" size="15"></td>
                    <td>
                        <select name="Divison">
                            <option value="L4D2">L4D2</option>
                            <option value="CSS">CSS</option>
                            <option value="GMOD">GMOD</option>
                            <option value="TF2">TF2</option>
                        </select>
                    </td>
                    <td>
                        <select name="Rank">
                            <option value="Division Leader">Division Leader</option>
                            <option value="Admin">Administrator</option>
                            <option value="Member">Member</option>
                        </select>
                    </td>
                </tr>';
    }
    echo     '<tr>
                    <td colspan="4" align="center"><input type="submit" name="Submit" value="Submit"></td>
                </tr>
               </table>
            </form>';
    
    // close connection
    mysql_close();
    ?>
    

    now replace whole coding with this one and reply…??

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

Sidebar

Related Questions

I have a mysql database that I'm trying to populate from a text file.
I am trying to pre-populate data to a token input field. But nothing gets
I am trying to populate a Postcode (ie zipcode) input field with data from
I am trying to auto-populate a text field based on the value of another
I am trying to auto-populate a text field based on the value of another
I'm trying to populate a table with user information in a MS SQL database
I'm trying to populate a dictionary dynamically in a for loop like so: pseudo-code
I'm trying to populate a List of beans from a form: public class Foo
I am trying to populate a variable with an XML response from an ajax
Has anyone used jquery to take data from one form field and put it

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.