Beta1.0 Posted February 23, 2010 Share Posted February 23, 2010 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. Quote Link to comment Share on other sites More sharing options...
haku Posted February 24, 2010 Share Posted February 24, 2010 Depends - are the delete buttons <input>s or <a>s? Quote Link to comment Share on other sites More sharing options...
Beta1.0 Posted February 24, 2010 Author Share Posted February 24, 2010 Hi Haku, The delete buttons are <img> currently, I was thinking of creating javascript onClick events to handle the clicks. Lets assume that I'll create the buttons as <a>...how would I go about storing the item_id? Quote Link to comment Share on other sites More sharing options...
haku Posted February 24, 2010 Share Posted February 24, 2010 <a href="www.example.com?id=23">Delete item 23</a> Notice the id is appended onto the URL. You will need to grab that id on the processing side, and deal with it as fit. Quote Link to comment Share on other sites More sharing options...
Beta1.0 Posted February 24, 2010 Author Share Posted February 24, 2010 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? Quote Link to comment Share on other sites More sharing options...
haku Posted February 24, 2010 Share Posted February 24, 2010 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. Quote Link to comment Share on other sites More sharing options...
Beta1.0 Posted February 24, 2010 Author Share Posted February 24, 2010 Thank you Quote Link to comment 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.