Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Insert, Display unit type.


bac3

Recommended Posts

Posted

In shoppingcart.php, After products_name defined, i add the following lines to display a new field in table products;

$str1 = 'select product_unit from '.TABLE_PRODUCTS.' where products_id ='.$products[$i]['id'];
$query = tep_db_query("$str1");
$product_unit = tep_db_fetch_array($query);

 

What's wrong is above code

 

Next to quantity input box, i add following line

$info_box_contents[$cur_row][] = array(
'align' => 'center',
'params' => 'class="productListing-data"valign="top"',
'text' => $product_unit);

 

But the product_unit return a string "Array", Why?

p1.gif

Posted

Try this:

 

$str1 = tep_db_query("select product_unit from " . TABLE_PRODUCTS . " where products_id ='" . $products[$i]['id'] . "'");
$query = tep_db_fetch_array($str1);
$product_unit = $query['product_unit'];

 

Matti

Posted

Thanks for reply first, but it returns nothing.

 

Finally i use a poor coding to finish it

 

      
@ $db = mysql_pconnect ("localhost", "root", "");
if (!$db) {	echo" Error: Could not connect to database. Please try again later.";
exit;
            }
	 
mysql_select_db("testing");
$str1 = 'select product_unit from products where products_id ='.$products[$i]['id'];
           $result = mysql_query($str1);
           $row = mysql_fetch_array($result, MYSQL_BOTH);
           product_unit2 = $row[0];

Archived

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

×
×
  • Create New...