iDontKnowOfAGoodUsername Posted November 20, 2012 Share Posted November 20, 2012 Hello, I currently have a table that displays a list of elements from a shop. The information comes from a postgreSQL database and is then shown on index.php using a table. The problem I have is I need to add a checkbox to the end of each row so when I select multiple items I can add them to basket. I have the 'select' column set up but no checkboxes as of yet. I need to first implement the checkboxes and then from there I can get and post the selected items into the basket.php page. Any help would be massively appreciated. This is probably something simple im just overseeing. Would rather you also explain than try and give a straight up answer as I am more likely to learn that way. Thank you Quote Link to comment https://forums.phpfreaks.com/topic/270953-adding-select-column-to-table-to-select-multiple-elements/ Share on other sites More sharing options...
akphidelt2007 Posted November 20, 2012 Share Posted November 20, 2012 (edited) Use a checkbox array... and add the database id as it's value. <input type='checkbox' name='ids[]' value='1'> //check $_POST ids if(isset($_POST['ids'])) { //loop through them foreach($_POST['ids'] as $id) { //$id is the id of the row selected. This is where you do whatever it is you want to record them for your basket } } Edited November 20, 2012 by akphidelt2007 Quote Link to comment https://forums.phpfreaks.com/topic/270953-adding-select-column-to-table-to-select-multiple-elements/#findComment-1393898 Share on other sites More sharing options...
iDontKnowOfAGoodUsername Posted November 20, 2012 Author Share Posted November 20, 2012 Use a checkbox array... and add the database id as it's value. <input type='checkbox' name='ids[]' value='1'> //check $_POST ids if(isset($_POST['ids'])) { //loop through them foreach($_POST['ids'] as $id) { //$id is the id of the row selected. This is where you do whatever it is you want to record them for your basket } } Thank you for your quick response. I will look into this now. Quote Link to comment https://forums.phpfreaks.com/topic/270953-adding-select-column-to-table-to-select-multiple-elements/#findComment-1393903 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.