alan543 Posted March 14, 2006 Share Posted March 14, 2006 Hi Folks,any help appreciated here.I have a simple Table (Table1) with 3 fields (ID, Date, Value).So if I query the DB for a certain date it lists the ID and value of all rows with that date. What I need to do is have a checkbox next to each table row and only the ID & Value of the rows that are checked should be posted to the next page where I will do a SUM to add the values together.Does anyone have any ideas on the best way to do this?Thanks in advance...Alan Quote Link to comment https://forums.phpfreaks.com/topic/4920-checkbox-in-phpmysql-rows/ Share on other sites More sharing options...
redbullmarky Posted March 14, 2006 Share Posted March 14, 2006 make sure all the checkboxes have the same 'name' attribute, but followed by square brackets, ie name="mycheckbox[]"by default, only the checkboxes that are checked will pass a value to your next script, and the checkbox values can be accessed with[code]$checkboxarray = $_POST['mycheckbox'];foreach ($checkboxarray as $checkvalue){ echo $checkvalue.'<br>';}[/code]unchecked boxes are automatically ignored anyway.cheers Quote Link to comment https://forums.phpfreaks.com/topic/4920-checkbox-in-phpmysql-rows/#findComment-17350 Share on other sites More sharing options...
alan543 Posted March 14, 2006 Author Share Posted March 14, 2006 Thanks for that. That works great for passing the value of the checkbox (i.e. on) But It's the other values in the row that I need to pass on if the checkbox is checked? Any ideas?Thanks Quote Link to comment https://forums.phpfreaks.com/topic/4920-checkbox-in-phpmysql-rows/#findComment-17385 Share on other sites More sharing options...
redbullmarky Posted March 14, 2006 Share Posted March 14, 2006 [!--quoteo(post=354911:date=Mar 14 2006, 03:24 PM:name=alan543)--][div class=\'quotetop\']QUOTE(alan543 @ Mar 14 2006, 03:24 PM) [snapback]354911[/snapback][/div][div class=\'quotemain\'][!--quotec--]Thanks for that. That works great for passing the value of the checkbox (i.e. on) But It's the other values in the row that I need to pass on if the checkbox is checked? Any ideas?Thanks[/quote]dont think i'm getting you. if a checkbox is checked, then it's VALUE is passed in the $_POST. if it's not checked, NOTHING is passed. can you be more specific about your problem?(has been a long day, so maybe i'm missing something simple) Quote Link to comment https://forums.phpfreaks.com/topic/4920-checkbox-in-phpmysql-rows/#findComment-17459 Share on other sites More sharing options...
alan543 Posted March 16, 2006 Author Share Posted March 16, 2006 It's ok I managed to do a workaround. Thanks for your help anyway.Cheers,Alan Quote Link to comment https://forums.phpfreaks.com/topic/4920-checkbox-in-phpmysql-rows/#findComment-18029 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.