I have a page on my site where I can optionaly filter by certain fields
(order by filesize or file category), but I am implementing a shopping cart
type of idea where users can submit an order.

As administrators, my coworkers and I need to be able to filter orders by
their contents. For example:

View all orders for "Jack and the Beanstalk," where an order may have Jack
and the Beanstalk and other items.

I have an order table that keeps track of the order_id, the date, the
status, etc. I also have an order_lineitem table that is the contents of the
order. This has a one-to-many structure (without foreign keys because it is

I was baffled as to how to filter the orders by the item_id that appears in
the order_lineitem table.

I just came up with this, but I'm not sure how the mysql_queries will handle
an array. Do I have to do some extensive regular expression management here
to get this to work, or will it accept an array?


if (isset($_POST['showid']))
   $showid = $_POST['showid'];
   $subSQL = "SELECT order_id FROM afy_show_lineitem WHERE show_id =
   $subResult = mysql_query($subSQL);
   $where = "WHERE";
   $extQuery = 'order_id = {$subResult}';

$resultOrders = mysql_query("SELECT * FROM afy_order {$where} {$extQuery};")
or die(mysql_error("Could not query the database!"));


Reply via email to