Optimalkiller Posted March 7, 2007 Share Posted March 7, 2007 I'm trying to list all the products with there product id numbers in an Invoice and this is the code that I'm am useing. $mfg_query3 = tep_db_query("SELECT products_id FROM orders_products where orders_id = '" . (int)$orders['orders_id'] . "'"); $result3 = tep_db_fetch_array($mfg_query3); echo $result3['products_id']; when youy run the SQL script in PHPMyadmin it list the 3 items fine with the different Products ID. now when running this via a PHP script what seems to happen is that the same product number is repeated per product item it should have a diffrent number per product Example 1 x MP3 Player Manufacturer Unavailable Product Item 1653 1 x USB Stick Manufacturer Unavailable Product Item 1653 1 x MP3 CD Player Manufacturer Unavailable Product Item 1653 Can anyone help me out to fix this problem Please :) Thanks Optimal Quote Link to comment Share on other sites More sharing options...
Optimalkiller Posted March 7, 2007 Author Share Posted March 7, 2007 O.k. now I have modify the script to this. $mfg_query4 = mysql_query("SELECT products_id FROM orders_products where orders_id = '" . (int)$orders['orders_id'] . "'"); while ( $row = mysql_fetch_array( $mfg_query4 ) ) { { echo $row['products_id'] . ' '; }} see below for the output. what I would like to see is each Product ID under each item not have all the product Id repeated the each item, (at least I'm getting all the correct Products ID) 1 x MP3 Player Manufacturer Unavailable Product Item 1653 287 392 1 x USB Stick Manufacturer Unavailable Product Item 1653 287 392 1 x MP3 CD Player Manufacturer Unavailable Product Item 1653 287 392 Help!!!! Quote Link to comment Share on other sites More sharing options...
Optimalkiller Posted March 7, 2007 Author Share Posted March 7, 2007 I think this bit of code is doing the same thing. for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { // BEGIN associate Manufacturer To Product $v_query = tep_db_query("select manufacturers_id from " . TABLE_PRODUCTS . " where products_id = '" . $order->products[$i]['id'] . "'"); $v = tep_db_fetch_array($v_query); // Select appropriate Manufacturers Name $mfg_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . $v['manufacturers_id'] . "'"); $mfg = tep_db_fetch_array($mfg_query); // END associate Manufacturer To Product ?> <b><a href="<?php echo tep_href_link(FILENAME_CATEGORIES, 'action=new_product_preview&read=only&pID=' . $order->products[$i]['id'] . '&origin=' . FILENAME_ORDERLIST . '&oID=' . (int)$orders['orders_id']); ?>"><?php echo '<br><font color="0000FF">' . $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name']; ?></font></a></b><br> Quote Link to comment Share on other sites More sharing options...
Optimalkiller Posted March 11, 2007 Author Share Posted March 11, 2007 I think this bit of code is doing the same thing. for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { // BEGIN associate Manufacturer To Product $v_query = tep_db_query("select manufacturers_id from " . TABLE_PRODUCTS . " where products_id = '" . $order->products[$i]['id'] . "'"); $v = tep_db_fetch_array($v_query); // Select appropriate Manufacturers Name $mfg_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . $v['manufacturers_id'] . "'"); $mfg = tep_db_fetch_array($mfg_query); // END associate Manufacturer To Product ?> <b><a href="<?php echo tep_href_link(FILENAME_CATEGORIES, 'action=new_product_preview&read=only&pID=' . $order->products[$i]['id'] . '&origin=' . FILENAME_ORDERLIST . '&oID=' . (int)$orders['orders_id']); ?>"><?php echo '<br><font color="0000FF">' . $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name']; ?></font></a></b><br> Problem Now Resolved Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.