Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Help comparing two fields and returning a


Colin

Recommended Posts

Hey guys,

I have two fields that I want to compare. They are manufacturers_id and intake_manifold.

 

I have written a page called packages.php.. Basically, want I want to do is return the number of entries that are in the database for a given manufacturer_id.

 

For example, if the product_id is 456 and that product's manufacturer_id is 11 I want to return all intake_manifold rows that match the manufacturer_id of 11. I want to do this because I set the 'type' of product when I add the product to the catalog.

 

Here's what I have so far. I get a returned value of 0. There are 14 entries in the database that are supposed to return.

 

<?php
   $product_match_array = array();
   $product_match_query = tep_db_query("select prod.products_id, prod.manufacturers_id, prod.intake_manifold prod.products_date_added, count(prod.products_intake_manifold_id) as total from " . TABLE_PRODUCTS . " prod where prod.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and prod.products_intake_manifold_id = prod.products_tire_intake_manifold_id group by prod.products_intake_manifold_id");
   if ($product_match['total'] < 1) { 
 if ($product_match_check->number_of_rows > 0) {
   $product_match_query = tep_db_query($product_match_check->sql_query);
   while ($product_match = tep_db_fetch_array($product_match_query)) { }
?>
<tr><td class="main" colspan="2"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $product_match['products_id']) . '"><b><u>' . $product_match['products_id'] . '</u></b></a><br>' . TEXT_DATE_ADDED . ' ' . tep_date_long($product_match['products_id']) . '<br>' . TEXT_DATE_ADDED . ' ' . tep_date_long($product_match['products_date_added']) . '<br>' . TEXT_MANUFACTURER . ' ' . $product_match['manufacturers_name'] . '<br><br>' . TEXT_PRICE . ' ' . $products_price; ?></td></tr>
<?php } else { ?><tr><td>not working</td></tr><?php } ?>

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...