What I am trying to do is as follow:

I have a html form with dropdownlists that populated by php and mysql, on the same page I have a table that displays the data that was enter in the form (obvious when submitted)

my table structure:

CustomerlocationId
ProducttypeId
Quantity
dateTimelastUpdate

my goal is when I add the CustomerLocationId(this value is fed by a $_POST) and the ProductTypeId to the table I want to be able remove the productTypeId that already was added and incase that the customerLocationId has more productTypeId's I want the remove them also from the dropdownlist

I look and the only way I saw it work is by the NOT IN statement

 SELECT
    product_types_tbl.ProductTypeId,
    product_types_tbl.ProductTypeName
    FROM
    product_types_tbl
    WHERE
    product_types_tbl.ProductTypeId NOT IN (2,8)
    ORDER BY
    product_types_tbl.ProductTypeName ASC

myquestion is how can I feed query one table and get the productTypeId's into the query above. I am guessing that the query need to go into an php array like:

$ProductTypeName_DL ="SELECT
product_types_tbl.ProductTypeId
FROM product_types_tbl ORDER BY ProductTypeName ASC" ; $ProductTypeName_dropdown = mysql_query($ProductTypeName_DL); if(!$ProductTypeName_dropdown) { echo"Could not successfully run query ($ProductTypeName_DL) from DB: ".mysql_error(); exit; } if(mysql_num_rows($ProductTypeName_dropdown) == 0) { echo "No rows found, nothing to print so am exiting"; exit; }



 while($ProductTypeName_row=mysql_fetch_array($ProductTypeName_dropdown))
 { 
    $row[] = $ProductTypeName_row["ProductTypeId"] ;
 }
 print $row;

 and then put $row into the first query:

 SELECT
product_types_tbl.ProductTypeId,
product_types_tbl.ProductTypeName
FROM
product_types_tbl
WHERE
product_types_tbl.ProductTypeId NOT IN ($row)
ORDER BY
product_types_tbl.ProductTypeName ASC

but I can seem to get it to work... any help is appreciated
thx

and then put $row into the first query:

$row = implode(',', $row);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.