Jump to content

Archived

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

yanks6rule

checkboxes

Recommended Posts

I have a table that is populated from a MySQL database. The first column of this table is a checkbox that has the value remove[$guestID]. I am giving the user the opportunity to remove a guest they are no longer bringing or have to edit.

If you have 3 guests with the following guestIDs 3, 6, 15 and you wanted to remove guest 15 you could check the last checkbox and I would want to check to see if any of the three checkboxes are marked and if they are I would remove the guest by matching the guestID to the value in the checkbox.

Does this make sense or am I over thinking a simple problem. I can supply code that I have, I think I have to put this into an array but not sure how to check for the value being checked or not checked.

Share this post


Link to post
Share on other sites
[code]
$sql = "delete from table WHERE guestid IN (";

foreach ($remove as $id) {
   $sql.="'$id',";
}
$sql = substr_replace($sql,"",-1);         
$sql.=")";
[/code]

edited to take out a superfluous var that i left in from when i c/p the code

Share this post


Link to post
Share on other sites
I find it easier just to use a join()

[code]$ids = join ("','" , $remove);

$sql = "DELETE FROM tablename WHERE id IN ('$ids')";[/code]

Share this post


Link to post
Share on other sites
barand, have i ever mentioned that you are the shiz? [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]

Share this post


Link to post
Share on other sites
As it's outside my aged vocabulary, I'm assuming it's a compliment ;-)

Share this post


Link to post
Share on other sites
yes, it's shortened form of shiznit, as in, you are the shiznit! Which is an alternate way of saying sh*t. As in, you are the sh*t!, or, you are the man!

and come on, you can't be THAT (much) old(er).. Judging by posting styles on these forums, I'd say I'm probably one of the older people around here...

Share this post


Link to post
Share on other sites

×

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.