submitting multi keys from table rows
Posted: Tue Sep 02, 2014 5:58 am
Hi, I am doing my first website after beginning my studies of HTML/PHP/Javascript/CSS/MySql in June 2014. The adminisrative stuff is done and tested (Specifically: registration, login, user forgot password processing, profile update). Okay so now the fun stuff (65 more pages of duplicating my MS-Access prototype database into this new WebSite technology). I think I know how to do this next challenge but thought I should run it by the PHP/Javascript experts.
The objective:
Produce a table of MySql data on the page. Each row is a record on the database and has the key hidden (I know how to do all this so far). The user can checkbox the rows they want to have added to their personal database, and after they have checked all the rows they want, they click submit and the record keys are added to their personal selection.
My theory as to how to do this:
I know how to select one key and go off to get another page. However to collect the keys for final submission is the new part. I am thinking I will need a hidden form at the top with a text field and I will append each key the user checks into that hidden text field and when they click submit the next whatever.php file will parse out the keys from this text box and add these to the user records. Assuming I am on the correct track so far I am thinking each row needs a button with an "onclick" event which calls a javascript function. Okay so I need to figure out how to get the record key of that row to the function much like the example I have from a book of getting the record key of the row into the hyperlink address. I remember now. The PHP code used a loop to build each table row and there was a variable called $RowsKey that was put in a hidden field and I could put this same $RowKey in the javascript function call. Once I get this far I know how to use the Javascript to append the key to the text box with a comma to separate the keys.
What what do you think? Is this the way to do it?
Thanks,
John
The objective:
Produce a table of MySql data on the page. Each row is a record on the database and has the key hidden (I know how to do all this so far). The user can checkbox the rows they want to have added to their personal database, and after they have checked all the rows they want, they click submit and the record keys are added to their personal selection.
My theory as to how to do this:
I know how to select one key and go off to get another page. However to collect the keys for final submission is the new part. I am thinking I will need a hidden form at the top with a text field and I will append each key the user checks into that hidden text field and when they click submit the next whatever.php file will parse out the keys from this text box and add these to the user records. Assuming I am on the correct track so far I am thinking each row needs a button with an "onclick" event which calls a javascript function. Okay so I need to figure out how to get the record key of that row to the function much like the example I have from a book of getting the record key of the row into the hyperlink address. I remember now. The PHP code used a loop to build each table row and there was a variable called $RowsKey that was put in a hidden field and I could put this same $RowKey in the javascript function call. Once I get this far I know how to use the Javascript to append the key to the text box with a comma to separate the keys.
What what do you think? Is this the way to do it?
Thanks,
John