The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.
I'm looking for some help on how to start looking for tutorials examples of something (terrible sentence).
Basically I have a page that does an mysql query for
fname lname date score cname result
and draws each row in the table with a while loop
e.g.
joe smith apr 25 95 john sale
This page works just fine.
What I want to do is click on a button and have a form show under each row in the table so I can do another query to submit new data for that row.
so say I wanted to update joe smith's score I would click on a button beside his row (at the end) and this would drop down a form with all the fields and a submit button so I could then do a query on submit to alter whatever data.
The problem is I have no idea where to even start looking for help on this. Any examples that are sort of like I describe would be hugely helpful and if any of the above is unclear (very likely) I'll try and clarify as best I can.
Aridhol on
0
Posts
admanbunionize your workplaceSeattle, WARegistered Userregular
edited May 2009
You're going to want to look at Javascript. Element.show() in particular. Basically, every row will have a hidden form beneath it that will be shown by hitting the button. There are other ways to do it (where the form doesn't even exist until you click the button, for example) but that's more complicated. Since you're going to be working with Javascript, you might want to look at Prototype; it cleans up a lot of really messy JS operations.
Also I got it to show the form when you click a radio button and hide it when you click another one.
Now the last challenge is to find out WHICH table row I have clicked the radio button for and take a piece of data from there (reps name) so when I have the form submit it updates the correct person.
I know it's not formatted very well.
So when I click button 1 I need to be able to get data for the row it's in, specifically the rep field.
EDIT: I used jquery and css (tutorial)
Aridhol on
0
admanbunionize your workplaceSeattle, WARegistered Userregular
edited May 2009
Not a big jump. Just put the buttons and form inside "echo" statements. So instead of <div id="form"> you have echo 'div id=form-"'. $<some unique value from the DB> . '">'. Likewise, instead of $('#form')... you have $('#form-' . $<same unique value>... etc.
I got it to show the rep name in the form (pulled from $rep) but it only does this for the first rep name. I would guess because it only creates the form the first time through and not for each row of the table.
to clarify, if I had
joe
john
jacob
josh
I'd like a radio button at the end of each row to show or hide a form (check)
I'd like the Rep field in the form to be populated with the rep name on that line
I could be wrong about the details of escaping quotes. I don't do a lot of PHP. But this is the basic idea: instead of creating just one form, you're creating one form for each row of the table. The form for rep "joe" would have the id "form-joe" and it's associated radio buttons will call $('form-joe').show()/hide().
This assumes that 'rep_name' is the key of your table. If it's not, you'll have some issues.
Posts
Also I got it to show the form when you click a radio button and hide it when you click another one.
Now the last challenge is to find out WHICH table row I have clicked the radio button for and take a piece of data from there (reps name) so when I have the form submit it updates the correct person.
I know it's not formatted very well.
So when I click button 1 I need to be able to get data for the row it's in, specifically the rep field.
EDIT: I used jquery and css (tutorial)
I got it to show the rep name in the form (pulled from $rep) but it only does this for the first rep name. I would guess because it only creates the form the first time through and not for each row of the table.
to clarify, if I had
joe
john
jacob
josh
I'd like a radio button at the end of each row to show or hide a form (check)
I'd like the Rep field in the form to be populated with the rep name on that line
Here is the complete code sans mysql db info
Becomes:
I could be wrong about the details of escaping quotes. I don't do a lot of PHP. But this is the basic idea: instead of creating just one form, you're creating one form for each row of the table. The form for rep "joe" would have the id "form-joe" and it's associated radio buttons will call $('form-joe').show()/hide().
This assumes that 'rep_name' is the key of your table. If it's not, you'll have some issues.