![]() |
|
#1
|
|||
|
|||
Script to manage InvoicesI am an amateur at coding so please forgive the probable naivety of this question.
Let me try to describe what it is i am trying to do. I have a table that is being populated by crew via the post method through a html page. The table has ID(auto) Time Invoice Amount Paid. Next i have a page that echos the data so it can be viewed by accounting and marked paid. this is were i am running into issues. i can only get the update to work on the last row echoed. What should i search for? Should i not be using echo? Code follows: Look up code PHP Code:
Update code PHP Code:
Last edited by admin : 29-Oct-2009 at 03:48.
Reason: Please insert your example PHP codes between [PHP] and [/PHP] tags
|
|||
|
#2
|
||||
|
||||
Re: You guys have helped me before, could you agian?If I understand correctly, even though all the lines differ, you are only getting the values of the last row?...and the expectation is to process every row when 'Update' is clicked?
This is happening because ALL the rows have the SAME control name and id. So, the last row WILL be the values used. Notice that in the update script, you are getting ONE posted Paid/id pair, and that will be the values of the very last row. You will need a way to have distinct name and pair references for EACH row that will need processing. For example, the id can be used to create concatenated references in the loop: (only applied to the name properties in this example) PHP Code:
Code:
__________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#3
|
|||
|
|||
Re: You guys have helped me before, could you agian?Thanks i can see what you did.
I've been kicking my self after reading it. One of my tries touched on this code but the try didn't work and i gave up on it. I'm hoping you can give me hint on the update code. i think im on the right path. Im trying to get the Post to have a variable that is equal to an array? |
|
#4
|
||||
|
||||
Re: You guys have helped me before, could you agian?Quote:
EDIT: Somewhere near the top of the update script, add this: PHP Code:
__________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#5
|
||||
|
||||
Re: Script to manage InvoicesFirst, let's examine the (markup) form that is meant for the "accounting" people. Within every INPUT element/tag you should set the TYPE attribute. For example:
HTML Code:
Because you have NOT set this attribute in your example markup above, it is difficult to understand how you expect this form to work. Second, you must uniquely identify each ID attribute in a single document. In other words, using "ID" as a common value for the id= attribute in more than one INPUT element is invalid. Read what the www.w3.org has to say about the ID attribute: Quote:
You should have described the DB column types with your question. I have no idea what goes into the `Paid` column or even what the differences are between the `ID` and `Invoice` columns in your database table structure. I assume `Paid` is a BIT/TINYINT(1)/BOOLEAN column where the values are either 1 or 0. I assume the `Invoice` and `ID` columns contain unique identifiers aka Invoice numbers. If so, why have both? Third, how does the form submission really work? Are all the invoices set to paid at once, or do you require they (the Invoices) be managed one or more at a time? How is the form to display records (invoices) that are already paid? If you had taken the time to explain your problem clearly, maybe you could have been assisted much sooner. If you wish the form to return an array within the superglobal $_POST array, the best idea is to set the name for the common elements like this: myvalues[], where $_POST["myvalues"] would be an array. For example: HTML Code:
Note the unique id attributes for each in the example markup. |
|
#6
|
|||
|
|||
Re: Script to manage InvoicesIt has taken me most of an hour trying to get my account reactivated. SO forgive me if i come across as a bit pissed.
For starters admin, accounting is accounting not "accounting". Just because my code isnt up to your high standards doesn't mean its not being used the way i say it is, it just means that a: Im new to php and not thinking clearly b: take shortcuts because i know were its going c: was taught differently, or in the case of php not at all. I believe you will find that my ID column is described as Auto, as in auto increment. TurboPT seemed to have no issue in understanding what i was looking for. and even was able to assist me greatly in fixing my idiotic mistake of not naming the ids/name differently. Something that i knew had to be done just couldn't figure how. he was even able to do it in a timely manner. You have assumed incorrectly about the PAID field. Look at my code, its a simple input. that is all. why? you don't need to know that. Quote:
PHP Code:
If your going to try to help at lest look at what i have instead of assuming im some 14 year old idiot looking for a free ride. -cheers. Last edited by admin : 02-Nov-2009 at 17:37.
Reason: Please insert your example PHP codes between [PHP] and [/PHP] tags
|
|
#7
|
||||
|
||||
Re: Script to manage InvoicesI have NEVER assumed anyone is here for a "free ride". I believe sharing knowledge, or anything else for that matter, is something very important in this world.
When you mentioned "marked paid", I understood that to mean that it was a ON/OFF thingy. I understand that you are pissed, but I am not. If I have offended you in any way, it was not intentional. |
|
#8
|
|||
|
|||
Re: Script to manage Invoicesunderstood.
I have many more things to read and try for the update script before i ask for more help here. Could you however try to explain your myvalues code again? Maybe what method your using so i can look it up? |
|
#9
|
||||
|
||||
Re: Script to manage InvoicesHere is a simple script that you can save as a PHP file that will demonstrate how the INPUT tags work.
PHP Code:
|
|
#10
|
|||
|
|||
Re: Script to manage InvoicesI think i get that.
i can not for the life of me figure out the update code here. i can get it to update one row, any row, as long as i tell it the ID, how do i get it to update all of them? any examples i find have you name the row or value you want to use. I hope this made sense, my head has about had it today. |
Recent GIDBlog
Once again, no time for hobbies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how do u guys know???? | devin | Open Discussion Forum | 9 | 06-Feb-2007 22:29 |
| + Hey Guys | EthicsD | New Member Introductions | 0 | 10-Oct-2006 11:39 |
| Newbie Problems. Help me guys | the_last_rites | Apache Web Server Forum | 4 | 18-Jan-2005 12:57 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The