Help Modifying Code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gaspower
Forum Newbie
Posts: 8
Joined: Fri Jun 13, 2008 6:04 pm
Location: Bend Oregon

Help Modifying Code

Post by gaspower »

Hello,

The below code gives me this output on the site,

AB-1000 Universal Brake Pads ***(which is the product name from the database)
GMC, Hummer ***(categories in which this particular parts is located in database)

Would like it to read like this, I keep trying to modify but keep breaking the site,

AB-1000 Universal Brake Pads ***(which is the product name from the database)
Fits Models: GMC, Hummer ***(categories in which this particular parts is located in database)

Thank you JR

Code: Select all

$lc_align = '';
            if(isset($HTTP_GET_VARS['language']))
            {
              $env_language = $HTTP_GET_VARS['language'];
              $language_query = tep_db_query("select languages_id from ". TABLE_LANGUAGES . " where code ='" . $env_language . "'");
              $language_arr = tep_db_fetch_array($language_query);
              $language_id = $language_arr['languages_id'];
            }
            else
            {
              $language_id = (int)$languages_id;
            }
              
$products_to_catagories_query = tep_db_query("SELECT categories_name FROM ". TABLE_PRODUCTS_TO_CATEGORIES ." p2c, ". TABLE_CATEGORIES_DESCRIPTION ." cd WHERE p2c.products_id = " . (int)$listing[$x]['products_id'] . " and p2c.categories_id = cd.categories_id and language_id ='".(int)$language_id."'");
            $category_list = " ";
            do
              {
                if($category_list != " ")
                $category_list .=" , ";
                    
                else
                   
                   $products_to_categories_array = tep_db_fetch_array($products_to_catagories_query);
                   $category_list .= $products_to_categories_array['categories_name'].'';
 
               }
            while($products_to_categories_array = tep_db_fetch_array($products_to_catagories_query));
            $category_list .="";
            if (isset($HTTP_GET_VARS['manufacturers_id'])) {
              $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a>'.'<br>
              '.$category_list;
            } else {
              $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a>'.'<br>
              '.$category_list;
            }
            break;
hansford
Forum Commoner
Posts: 91
Joined: Mon May 26, 2008 12:38 am

Re: Help Modifying Code

Post by hansford »

that's all going to be in the way you structure your loops through the database. Say you have a while loop that gets the product name
you echo out the product name and Fits Models: open another query
and loop through and echo the models.
gaspower
Forum Newbie
Posts: 8
Joined: Fri Jun 13, 2008 6:04 pm
Location: Bend Oregon

Re: Help Modifying Code

Post by gaspower »

Hello,

Thank you for you response. Currently it works fine and I get the output I want, I just want to add the text "Fits Models" in front of the categories output which is,

# $products_to_categories_array = tep_db_fetch_array($products_to_catagories_query);
# $category_list .= $products_to_categories_array['categories_name'].'';

This code gives me,

GMC, Hummer output.

I would like to add the text "Fits Models" in front of GMC, Hummer. I tried adding $category_list .=" Fits Models "; , but it keeps breaking the page?

Thanks JR
WebbieDave
Forum Contributor
Posts: 213
Joined: Sun Jul 15, 2007 7:07 am

Re: Help Modifying Code

Post by WebbieDave »

Try changing the lines 31 and 34 from:

Code: Select all

 
'.$category_list;
 
To:

Code: Select all

 
' . 'Fits Models: ' . $category_list;
 
Post Reply