How do I insert data from a database into a form?

Links for php scripts

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 126
Joined: Tue Mar 01, 2016 3:07 pm

Fri Jan 06, 2017 4:12 pm


Just a quick query.
I've just started to build a editing form (on paper first), and a very rough idea in php.

I just wanted to ask, once I get started, I'm looking to pull a record from the database and insert it in a form for editing.
Am I correct in thinking, to enter text in a form text box I use the code

Code: Select all

<td><input name="txtaccountname" value="<?= $row['account_name'] ?>" size="20" maxlength="50"></td> 

User avatar
php-forum Active User
php-forum Active User
Posts: 315
Joined: Sat Mar 23, 2013 8:24 am
Location: Livonia, MI

Sat Jan 07, 2017 3:39 am

you forgot type in your input tag, but other than that it looks OK.

If you're are having trouble with the remote server in not working then I suggest changing the short tags to stand PHP tags, by that I mean :


Code: Select all

value="<?= $row['account_name'] ?>"

Code: Select all

value="<?php echo $row['account_name']; ?>"

Post Reply