Jump to content

problem using foreach and implode functions


needs_upgrade

Recommended Posts

Hello guys!

 

I want to make a query like this:

SELECT service_id FROM services WHERE service_id NOT IN ( 4, 6, 8, 12)

but the values in the "NOT IN" clause will be taken from an array from a group of checkboxes. This is my code:

 

<?PHP
$pid_array = $_POST[pid];

$sql = 'SELECT service_id FROM services WHERE service_id NOT IN (';
foreach ($pid_array as $service_id) {
     $sql .= "".implode(", ", $service_id)."";
}
$sql .= ')';
mysql_query($sql);
?>

 

It says : Warning: implode() [function.implode]: Invalid arguments passed

Thanks guys

 

Archived

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

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