Hi all,
I'm new to PHP and am building a PHP/HTML form on a page for users to enter data into a MySQL db. I've got everything working and, as they say, have learned a lot of lessons (made mistakes) along the way.![]()
My question regarding this form is more about style/methods of coding:
Currently, if users want to edit data existing in a record, they (for example) click a link to "edit record 1". This will take them to the form and php prefills the form with the data from record 1. If users are entering new data, the same form is presented blank.
At first I split up the form HTML with a lot of little php code snippets to set (prefill) the form element values.
Then I got the idea of generating the form and writing some JS to fill in the form values. I don't like this idea b/c of the extra code created - the final page source code is longer than needed.
So I am back to my first idea but I don't like it b/c of all the intermingling of php and html. I don't think it is elegant and it won't be as easy changing the HTML if I could get more separation.
Any thoughts on a better way?
Many thanks!


LinkBack URL
About LinkBacks




Reply With Quote

Bookmarks