Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Call tables and columns from DB


Hostecom

Recommended Posts

Hi, i use oscommerce 2.2ms

 

I have create 2 columns in producs_descriptions table for add more information to my products.

 

I can call and show this columns in product_info.php file but i want to call them too in product_listing.php file.

 

I have tried to add (in product_listing.php):

 

 $product_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
 
$product_check = tep_db_fetch_array($product_check_query);
 

$query = "select p.products_id, pd.products_name, pd.products_description, pd.products_minidescripcion, pd.products_FIRST_NEW_COLUMN, pd.products_SECOND_NEW_COLUMN, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id, p.products_type";

 

but when i call this products_FIST_NEW_COLUMN as i do perfectly in product_info.php, it doesn't show results.

 

Can any one help me with correct sentence for show results?

 

Best Regards!

Link to comment
Share on other sites

pd.products_FIRST_NEW_COLUMN

 

should probably be

 

pd.FIRST_NEW_COLUMN

 

pd is alias for products_description table

 

also $query doesn't look like a real query yet, it only lists colums to show, but misses from and where clause

 

 

if you post your complete product_listing.php we at least know what is going on exactly.

 

the listing_sql is composed in index.php normally, not in the product_listing.php module

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

just to say, we (volunteers on the forum) don't mind helping a little left and right, but we want to do it efficiently, not wasting our time ...

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

Hi, maybe i haven't explain good, im sorry.

 

I have a new colum in product_description table: products_newcolumn

 

in "product_info.php" i call this column for show a text:

 

 $product_info['products_newcolumn'] as i call the product name with $product_info['products_name']  and works perfect in "product_info.php" i can show products_newcolumn text perfectly.

 

I need to call the same "products_newcolumn" in "product_listing.php" file ( i know thats its a module related with index.php)

 

but i don't know how to recreate "$product_info['products_newcolumn']" in "product_listing.php" for show the text inside my newcolumn.

 

In "product_listing.php" I have tried to recreate first, the sentence of $product_info (as appears in "product_info.php" file):

 

$product_info_query = tep_db_query("select pd.products_name,pd.products_description, p.products_model from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
 
$product_info = tep_db_fetch_array($product_info_query);
 
$query = "select p.products_id, pd.products_name, pd.products_description, pd.products_newcolumn, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id, p.products_type";
 
but when i call to $product_info['products_newcolumn'] nothing shows in screen (no errors and no results)
 
I have tried to understand code because in "product_listing.php" the file call to products_name, products_price, etc, but i can't find how to call my new column, products_newcolumn (both them from producs_description table)
 
My apologies for my poor english.
Link to comment
Share on other sites

Hi

 

As @@bruyndoncx has already pointed out, you simply must add your products_newcolumn to the $listing_sql (4x) in the index.php => pd.products_newcolumn. Then you can use it in the product_listing.php with $listing['products_newcolumn']. ;)

 

J.J.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...