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

Links for php scripts

Moderators: egami, macek, gesf

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

Fri Jan 06, 2017 4:12 pm

Hello.

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> 
Thanks.

User avatar
Strider64
php-forum Active User
php-forum Active User
Posts: 306
Joined: Sat Mar 23, 2013 8:24 am

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 :

From

Code: Select all

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

Code: Select all

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

Post Reply