stopblackholes Posted May 12, 2008 Share Posted May 12, 2008 I cant figure out what the problem is. i know it has to do with $deletelist += line. if i echo just the value it has correct value but if i try and add it to the string of values for the mysql query i get 00000 no '1','2' ect. <?php $deletelist=""; $deletecounter=0; print_r($_POST['checkbox']); //// array of selected checkboxes foreach($_POST['checkbox'] as $key => $value) { echo $value; /// comes back with correct value echo $deletelist += "'".$value."'"; // does not! comes back 0 if($deletecounter>0){$deletelist += ","; } $deletecounter++; } mysql_query("DELETE FROM posts WHERE post_id in ($deletelist)")or die(mysql_error()); ?> Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted May 12, 2008 Share Posted May 12, 2008 remove the "+=" and use ".=" Quote Link to comment Share on other sites More sharing options...
Psycho Posted May 12, 2008 Share Posted May 12, 2008 This will be a little more efficient: <?php $deletelist= "'" . implode("', '", $_POST['checkbox']) . "'"; $query = "DELETE FROM posts WHERE post_id in ($deletelist)"; mysql_query($query)or die(mysql_error()."<br />QUERY: $query"); ?> Quote Link to comment Share on other sites More sharing options...
stopblackholes Posted May 12, 2008 Author Share Posted May 12, 2008 Thanks guys! ah i always confuse += operator with .= yeah the way you do it looks cleaner. Quote Link to comment Share on other sites More sharing options...
corbin Posted May 12, 2008 Share Posted May 12, 2008 += adds numbers, and .= strings. Remember the + as in addition and . as in period and it's easier ;p. Quote Link to comment 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.