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
https://forums.phpfreaks.com/topic/192699-newbie-here-can-i-put-data-into-a-form/
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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.