Jump to content

Recommended Posts

I have some code that I am working with that only deletes one item at a time when it is supposed to delete multiple items...

 

function removeItem()
{
	$d = JRequest::getCmd('section');
	$option = JRequest::getCmd('option');

	$this->setRedirect('index.php?option=' . $option . '&section=' . $d);

	$db	=& JFactory::getDBO();
	$cid = JRequest::getVar('cid', array(), 'request', 'array');
	$count = count($cid);
	$id = implode(',',$cid);

	if ($count)
	{
		$db->setQuery('DELETE FROM #__' . $d . ' WHERE rowid = "' . $id . '"');

		if (!$db->query()) {
			JError::raiseWarning( 500, $db->getError() );
		}

		if ($count > 1) {
			$s = 's';
		} else {
			$s = '';
		}

		$this->setMessage('Message' . $s . ' removed ' . $id);
	}
}

 

When I print out the items deleted using

$this->setMessage('Message' . $s . ' removed ' . $id);

 

It shows all of the items that were "deleted" but the query only deletes the first item in the list... any ideas?

Mysql IN Operator

 

Yea, that was my mistake on the single quotes. I meant to remove them all together.

 

Basically the IN operator acts as an OR statement, if the row_id is 1 OR the row_id is 2  execute this on those row_ids.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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