Link to home
Start Free TrialLog in
Avatar of damianb123
damianb123Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Find only database rows which have been ticked by checkbox

Hi,
   I am looking to output a series of rows of data from my database, then have a tick box on each row which can be ticked.  Once the tick boxes have been ticked, a button is pressed which then ONLY leaves or displays the ticked records - a sort of compare mechanism....

Can anyone help me out?

Cheers in advance.

D
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

You just need a CSS class with display:none.

Then for the click event on the buttun you just fire a script to iterate through the checkboxes and change the className property to the class with display:hidden where the checkbox checked property is false.

Changing the className value is much more efficient then changing the style properties directly through the style property.

Cd&
Avatar of damianb123

ASKER

The logistics of what is required I can do myself, it's the 'experts' help on the actual code - but thanks anyway!
You post a high leve description with no code or structual detail and you expect us to fetch you code out of thin air without having any context? Interesting.

To begin with we are here to help you find solutions, not do your work for you.  If you need sample code then you should post what you have so we can give you the hooks or modifications you need.

Cd&
You know what I only came back to this site recently to get help from 'experts' - it used to be very good.....  I don't think I've had a single question answered as yet, you seem to comment on them all, with nothing constructive to say!  Please stop commenting on my questions.....  I haven't seen anything which makes me think you know much more than me!!!
Sorry to hear you are not having a good experience on the site.  As you have indicated you are not interested in my help, I wiil avoid your questions, please point out my mistake if I post in one of your questions. I volunteer to help on EE and there are enough members happy to do things the way I prefer them because they get the solutions they need.

Perhaps you fail to understand the relationship.  You are not the boss and you have absolutely no power or right to make demands on volunteer Experts who or may not decide to offer help.

If you want to improve your experience on EE and other tech support sites you might try understanding the relationships on Q/A sites.

Cd&
See if this article is helpful.  It uses links instead of checkboxes, but the concepts are pretty close
https://www.experts-exchange.com/Programming/Languages/Scripting/PHP/A_12335-PHP-and-MySQLi-Table-Maintenance.html

For your checkbox application you will want to create an array of values in the checkboxes, so the checkboxes will be named something like this.  The value of $id will be the auto_increment key of the row that you want to identify.  You can get these keys from a standard SELECT query, and you can use the query results set to build your HTML form.

<input type="checkbox" name="box[$id] />

When the HTML form is submitted you will be able to find the checked boxes by using var_dump() to print out the contents of the $_REQUEST variable.

If I have a chance later I may be able to show you an example, but before I do that, please read the article and post any questions you have about it back here.

Best regards, ~Ray
Ray,
     Many thanks for this, i managed to get it working for a single value which is ticked by using the checkbox array, the trouble is if i have more than one row ticked then the array just looks like a string of numbers ie 2456, rather than 2,4,5,6, so when i perform my select statement it will only work for single checkbox ticks.  How can i change it so my select statement perform a WHERE ID = 2,4,5,6???

I hope that makes sense.

Thanks for your help.  Much appreciated.
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks so much Ray, after a bit of learning on the implode routine (very handy to know) it works a treat.... many thanks for all your help with this.

Damian
Glad to help.  Thanks for the points and thanks for using E-E, ~Ray