Jump to content

What's the opposite of id IN ('$id array')


cstegner

Recommended Posts

[!--quoteo(post=374657:date=May 17 2006, 10:27 AM:name=cstegner)--][div class=\'quotetop\']QUOTE(cstegner @ May 17 2006, 10:27 AM) [snapback]374657[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I need a query that will in essence be saying NOT IN ('$id_array') how do I do that?
[/quote]

if you have an array in a variable, just implode it with the quotes you need and stick it right into your query:

[code]
<?php
$array = array("blue", "green", "violet");
$sql = mysql_query("SELECT * FROM tableName WHERE color NOT IN ('" . implode("', '", $array) . "')");
?>
[/code]

good luck!

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.