Jump to content

How To Get Data From Html Table?


darkfox

Recommended Posts

so this is the scenario, i am creating an admin page using php and html and i do have an HTML table that is being populated dynamically, so what i want to do is, when i click the table row, i will be redirected to another page and print the details of the product i clicked from the table.

i really got lost here.. i dont really need the whole code/answer, i just need to know how to extract the text that is clicked from the table

 

thanks in advance guys! :)

Link to comment
Share on other sites

what he's saying is that then you are echoing out the table contents make a lint that includes the product id as a url variable that the recieving page can then lookup.

while($row = mysql_fetch_assoc($result)){
echo "<tr><td><a href=\"path_name/filename.php?pid={$row['product id']}\">{$row['product id']}</td><td>{$row['product name']}</td><td>{$row['quantity']}</td><td>{$row['ammount']}</td></tr>
}

That will then pass the product id through to the receiving page which can access it through the $_GET['pid'] call.

 

Does that make more sense?

Link to comment
Share on other sites

oh.. ok sir, now that make sense! thanks alot sir! i owe you one :) and sir btw, how can i make it as a javascript code? coz i made an onclick function on <tr> so that i will not be using the '<a>' link to make it more presentable and make all columns clickable sir , do you have any idea? sorry for lots of questions sir.. thanks again :))

Link to comment
Share on other sites

Use both, that way you know it'll work regardless of what browser your users use. I also recommend doing the page without the JS methods first, so that you don't try to do too much at the same time. JS can easily be added into the mix after everything's up and running, after all.

 

Lastly, I'd probably look into jQuery for this, if I were you; It'll help make things easier for you in the long run, but only if you've read up on basic Javascript syntax first.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.