Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

SQL & PHP Expert needed


Recommended Posts

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

Link to comment
Share on other sites

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!!!!

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...