Jump to content

Newbie here - Can I put data into a form?


SteveMann

Recommended Posts

Maybe I am asking the wrong question, but I've spent an hour looking through the forum here and can't find anything to answer my question.

 

I have a form in my HTML file, and data in a database.  Is here a way that I can put data from the database into the form for display or editing?  I have the data entry *into* my database working pretty well, and now I am building an admin page where I can call up a record from the database and edit it.

 

I suspect that I need to create the table in the PHP section after I read the data from the database.  Is this correct or do I need to do more reading?

 

TIA

Steve

Link to comment
Share on other sites

If the query hasnt been performed the above response will launch an error about unset variables so make sure you protect it:

 

value="<?php if(isset($row['first_name'])) { echo $row['first_name']; } ?>"

 

or use:

if(!$result) { 
    $row = new array(); 
}

 

or similar

Link to comment
Share on other sites

Thanks, but I already do a query to generate a CSV file and to show the data, but I want to pre-populate a form for editing.  In other words, I want to use the same form as the 'data entry --> post' form, but ask for a key (record number in this case), then retrieve that row of data and populate the same form for editing.  Can  even do that?  I am thinking that I have to build the form dynamically in PHP, but I still don't know how to fill the field in the form.

 

TIA

Steve

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.