Jump to content

Reading HTML Table Values


Panz3r

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/71373-reading-html-table-values/
Share on other sites

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.