Jump to content


Photo

checkboxes


  • Please log in to reply
5 replies to this topic

#1 yanks6rule

yanks6rule
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 14 May 2006 - 10:37 PM

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.

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 14 May 2006 - 11:32 PM

$sql = "delete from table WHERE guestid IN (";

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

edited to take out a superfluous var that i left in from when i c/p the code
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 16 May 2006 - 06:27 PM

I find it easier just to use a join()

$ids = join ("','" , $remove);

$sql = "DELETE FROM tablename WHERE id IN ('$ids')";

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#4 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 16 May 2006 - 11:16 PM

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\" /]
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#5 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 16 May 2006 - 11:23 PM

As it's outside my aged vocabulary, I'm assuming it's a compliment ;-)
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#6 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 17 May 2006 - 12:25 AM

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...
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users