Jump to content

What is the best way to reference an id of a table item?


Beta1.0

Recommended Posts

Hi all,

 

I have a database with a list of items. Each item has an id (item_id). I display all these items in an HTML table in which each item has a delete button.

 

I would some how need to store the item_id some where so that I would be able to access it when the delete button is pressed...Where could I store it? What would be the best way to approach this problem?

 

Thank you in advance.

Link to comment
Share on other sites

I am trying to avoid using the ?id=123 in the address bar. Is there another way?

 

I looked at how gmail manages email rows...

 

<div class="yW" id=":p7"><span email="contact@phpfreaks.com" class="yP">PHP Freaks Forums</span> (2)</div>

 

I guess they also have the id in the div tag...hmm...I wonder if they have a function that catches click events and then basically retrieves the id from the item clicked on...do you think this is the case here?

Link to comment
Share on other sites

Very possible. But impossible to say conclusively without knowing their backend code.

 

You have two options:

1) Use URL rewrite in your .htaccess (apache servers only) so that your url looks like example.com/delete/123 (rewriting the URL to example.com/delete.php?id=123

2) Using a backend PHP solution to read the ID tags as you theorized that google may be doing. In such a case, you should probably open a new thread in the php help section of the forum as it's not HTML at all.

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.