PHP code for selecting data from html table

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
neo.mn
Forum Newbie
Posts: 1
Joined: Tue Aug 17, 2010 9:10 pm

PHP code for selecting data from html table

Post by neo.mn »

Dear All

I would like to develop a php program. The program will like there will be several html text box in a html form. Bellow the text box there will be a simple button name ADD. After filling the text box when I press the add button all the data will be stored in tabular format bellow the ADD button. Each time I press the ADD button a new table row will be appended containing the text box data. Finally there will be a Submit Button after the table. When I press the submit button all code containing in table will be saved into the database. All this I would like to do using PHP or PHP and Javascript in combine and nothing else. Now I would like to request you all to help me to have a solution of the problem.

Thanks to you all.
ryanjones102
Forum Newbie
Posts: 5
Joined: Sat Aug 21, 2010 12:49 pm

Re: PHP code for selecting data from html table

Post by ryanjones102 »

I'd probably store the record entries into a table called "temp" and use a for each loop to retrieve the records in that table as you are adding them then when you wish to "add them to the database" i'd do something like a for each loop for the records in temp and insert them into your "real" table while simultaneously deleting them from your temp table. But it's a convoluted way of doing things. Any particular reason why you can't add them to the database in the first instance? Depends on your end user I guess. But that's how I'd do it 9 times out of 10.

I guess you could use JavaScript to do it also as suggested, but you're really relying on client side for heavy amounts of data there, are you really prepared to re-enter all of your data if firefox crashes.

I'd sit down and think exactly what you want to use this for, and if it is a simple entry form and only you are going to use it, then it's just a case of a $_POST['boxname1'] etc. all forced into a SQL statement, but if the box you're using is connected to the internet then there are MANY MANY more considerations. You're going to need to clean all user input to make sure there are no malicious bits of code (google SQL Injections) before you insert them. You also might want to validate any inputs.... I think you're best bet would be buying a book designed at teaching the basics of a LAMP (Linux, Apache, MySQL, PHP) set up. As you work through the book, I'm sure one of the projects will cover everything you need in your post. But to do the job correctly, it won't be as easy as you think.

Good luck.
Post Reply