Panz3r Posted October 1, 2007 Share Posted October 1, 2007 So I have a webpage I'm working on that uses javascript and PHP to manage a table that contains rankings. The users selects, using radio buttons, their top 5 specializations. As they are selected they are inserted into an HTML table at the base of the page using javascript. My question is, I want to save these values into a mysql table when the save button is clicked and I need to be able to pass the current value sin the table to php variables so I can use them in mysql queries. Is there any way to do this? Thanks, KC Quote Link to comment https://forums.phpfreaks.com/topic/71373-reading-html-table-values/ Share on other sites More sharing options...
shocker-z Posted October 1, 2007 Share Posted October 1, 2007 well as you are saving using javascipt then when you click the save button make that also submit the form therefore directing all the radio button variables ot the other poage so you can bring in the details to php with $_POST['radio_button_name'] Liam Quote Link to comment https://forums.phpfreaks.com/topic/71373-reading-html-table-values/#findComment-359148 Share on other sites More sharing options...
dbo Posted October 1, 2007 Share Posted October 1, 2007 You'll have to store the data in some type of form variables to be able to access it in PHP, for example a hidden field value. Quote Link to comment https://forums.phpfreaks.com/topic/71373-reading-html-table-values/#findComment-359150 Share on other sites More sharing options...
Panz3r Posted October 1, 2007 Author Share Posted October 1, 2007 You'll have to store the data in some type of form variables to be able to access it in PHP, for example a hidden field value. well as you are saving using javascipt then when you click the save button make that also submit the form therefore directing all the radio button variables ot the other poage so you can bring in the details to php with $_POST['radio_button_name'] Liam Well heres a sample from my table: <tr><td align="center">4</td><TD WIDTH=1 BGCOLOR="black"><SPACER TYPE="block" WIDTH=1></TD><td align="center"><span id="label4"><?php print($rank4[0]);?></span></td><TD WIDTH=1 BGCOLOR="black"><SPACER TYPE="block" WIDTH=1></TD> <td align="center"><span id="label4e"><?php print($rank4[2]);?></td><TD WIDTH=1 BGCOLOR="black"><SPACER TYPE="block" WIDTH=1></TD><td align="center"><span id="label4a"><?php print($rank4[3]);?></td><TD WIDTH=1 BGCOLOR="black"><SPACER TYPE="block" WIDTH=1></TD><td align="center"><span id="label4w"><?php print($rank4[4]);?></td><TD WIDTH=1 BGCOLOR="black"><SPACER TYPE="block" WIDTH=1></TD></tr> I basically wanna grab the current values held in span ids:label4, label4e, label4a, label4w and be able to toss em inside php variables Everything in my page is inside a form and I already use POST to grab some other info, so could I just do something like: $label4 = $_POST['label4']; I've tried something like that but it didnt seem to work. Can I use the span id to do that or do I need something else? Thanks KC Quote Link to comment https://forums.phpfreaks.com/topic/71373-reading-html-table-values/#findComment-359241 Share on other sites More sharing options...
BlueSkyIS Posted October 1, 2007 Share Posted October 1, 2007 Can I use the span id to do that or do I need something else? You need a form element inside the <form> tags for example a hidden field value. Quote Link to comment https://forums.phpfreaks.com/topic/71373-reading-html-table-values/#findComment-359293 Share on other sites More sharing options...
cooldude832 Posted October 1, 2007 Share Posted October 1, 2007 Technically no you can not read data in html elements based on their id, however you can use the fopen to a url and then using string manipulations get what you want. There might actually be a function developed by someone out there that lets you say find me all data in the span class header or something like that, it could be done, however the problem is it is displaying data that is already being pulled off a database so maybe you should trying getting the inital db values Quote Link to comment https://forums.phpfreaks.com/topic/71373-reading-html-table-values/#findComment-359313 Share on other sites More sharing options...
dbo Posted October 1, 2007 Share Posted October 1, 2007 Or.... you could do it a much cleaner way by modifying your add to table code to drop the values (or modify) inside of a hidden form field so that you can easily access them via PHP. Quote Link to comment https://forums.phpfreaks.com/topic/71373-reading-html-table-values/#findComment-359512 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.