Jump to content

Checkbox in PHP/MySQL rows


alan543

Recommended Posts

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
Link to comment
https://forums.phpfreaks.com/topic/4920-checkbox-in-phpmysql-rows/
Share on other sites

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
[!--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)

Archived

This topic is now archived and is closed to further replies.

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