Using PHP and MySQL, I have written an inventory program for work. It works well, but now they want me to add an "import" function. Rather than than ftping an Excel file to the server, I thought it would be easier -- and the less user work -- to create an Excel-like form to enter the new parts' information into a webpage form, grab the data, and then send it to the database.

I want the form to keep adding new rows until the user hits either the CANCEL or SUBMIT button, but I'm not sure how to do this. Probably a do-while loop, but I can't get the specifics worked out.

Can anyone help me get started?

Thanks! Cheryl

  • Do you have a screen capture that you can share? It feels like this is a user interface / front-end solution rather than a backend solution. Riley W. over 6 years ago

3 answers

0
points

Hard to tell exactly what you need based off just the text, can you post example code of the form? (ie what is it written in)

My knee-jerk reaction is to use Javascript (see: jQuery) to add dynamic ability to the form, something like this:

http://stackoverflow.com/questions/2145012/adding-rows-dynamically-with-jquery

Answered over 6 years ago by Bryan Taylor
  • I'm sorry but since this is work related and I work in a classified area, I can't be any more specific or post code. It is written in PHP/HTML/MySQL, languages I've learned for this project. I don't know Javascript. But I guess I can go learn it too... Cheryl over 6 years ago
0
points

I believe that what you are looking for would either require AJAX or JavaScript. AJAX requires JavaScript too, but the hard work can be done in PHP that way. You will need a loop, but that loop will be to all previously added rows, and you will want to remake the table entirely each time a new value is entered.

You could just do this with a simple form and PHP where the form makes a request and PHP session keeps track of each submission where each added row appears on the next page. Then, there will be a separate form submit button that sends the final results to be processed as such. Once that is done, use AJAX to make it dynamic so the user can stay on the same page.

Answered over 6 years ago by kainosnous
  • Java does seem to be the way to go. I've ordered a book (Learning PHP, MySQL, and JavaScript: A Step-By-Step Guide to Creating Dynamic Websites (Animal Guide) by Robin Nixon). It should arrive on Monday. Thanks, everyone! Other suggestions are also welcome! Cheryl over 6 years ago
  • The JavaScript will help make it dynamic, but just remember that first you will want to get it to work without it. Pure PHP should be able to handle it by itself. kainosnous over 6 years ago
Adar 0
0
points

I can suggest you to use php form. You would be able to create unlimited forms with any number of fields and place them anywhere on your web site. It is a self hosted version, but they use reliable bristol hosting

Answered over 6 years ago by Adar