![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Web Design & Programming Discussion of web design, and server-side & client-side scripting |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Sep 2008
Posts: 18
OS: WindowsXP SP3
|
Help me troubleshoot/tweak my PHP code
Inserting Multiple Rows - MySQL PHP Page.
Sorry for all the questions. I'm having trouble inserting multiple rows into the MySQL DB via a PHP/HTML form. I've got a table setup like so - Table name - timesheet Columns - id (auto increment) uname - entrydate state hours. And I'm trying to get a HTML form working with PHP so that they can insert into the database. Right now I've got it sort of working with the code below (At the moemnt I've got both the PHP code and the HTML form on one page, but I will change this) PHP Code:
a) The STATE input box is just for text, what i'm after is a drop down list so that users can only select from VIC, NSW, TAS, QLD, WA, etc. If somebody goes and types in for example 'VIC." with a fullstop or a space or something like VICTORIA, it's going to **** up all my other queries later on. b) This form only works for putting in one row, what I want is to be able to have a form that can insert multiple rows with a single click. Eg - $uname sent to the 'uname' column (Hidden) (I have a login/authentication system in place so once they're logged in it just ads their name in) At the Top - [Datebox] [Clickable Calander to set date] Then below - STATE HOURS VIC x.x WA x.x TAS x.x QLD x.x TAS x.x [SUBMIT] So this way it'd put in the amount of hours they do for each state. uname=test entrydate- 2008-08-10 state=VIC hours=2.4 uname=test entrydate- 2008-08-10 state=WA hours=3.8 Is this possible? Have been looking up arrays and loops but all the examples I've found are too techncial and I have a hard time adjusting it to work for me. |
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#2 (permalink) |
|
Design Team Member
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,879
OS: Vista, various linux distros
|
Re: Help me troubleshoot/tweak my PHP code
Hey, i have an answer for your first question:
a) just use a regular select element: Code:
<select name="state"> <option value="VIC">VIC</option> <option value="NSW">NSW</option> <!-- and so on... --> </select> As for posting multiple rows in one click, i've done something along the lines of this using javascript, basically you add to the form dynamically and check for each of the posted items... The process would be adding a button which add's a new row (state+hours) then when the form's submitted parse them all... If you want me to go through this please post back saying so. Cheers, Jamey |
|
|
|
![]() |
| Thread Tools | |
|
|