Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

browse alphabetically


Guest

Recommended Posts

has anyone made a contrib for this yet?

 

i hav a category that has all my products in it (over 1300), one page shows 20 products per listing, so it would mean meany pages.

 

what i am looking for is to browse thru that section by clicking on the desired alphabet character, ie. if i want to view products on "Detox" i would click on the 'D' and it will show me all products in that category with the titles starting with the letter 'D'

 

i cant seem to find a contrib for this on:

http://www.oscommerce.com/community/contributions

 

if i am looking in the wrong place please help me out...

would appreciate it a lot ^^

Link to comment
Share on other sites

Yeah, first you'd need to pass the first letter into the query string like this..

 

  $firstletter=$HTTP_GET_VARS['fl'];
   if (!$HTTP_GET_VARS['page']){
  	 $where="where p.products_status=1 and pd.products_name like '$firstletter%'";
   }else {
  	 $where="where p.products_status=1";
   }

 

The control display would look something like this...

 

          $firstletter_nav=
         '<a href="' . tep_href_link("allprods.php",  'fl=A', 'NONSSL') . '"> A |</A>' . 
         '<a href="' . tep_href_link("allprods.php",  'fl=B', 'NONSSL') . '"> B |</A>' .
         '<a href="' . tep_href_link("allprods.php",  'fl=C', 'NONSSL') . '"> C |</A>' .
         '<a href="' . tep_href_link("allprods.php",  'fl=D', 'NONSSL') . '"> D |</A>' .
         '<a href="' . tep_href_link("allprods.php",  'fl=E', 'NONSSL') . '"> E |</A>' .
         '<a href="' . tep_href_link("allprods.php",  'fl=F', 'NONSSL') . '"> F |</A>' .
         '<a href="' . tep_href_link("allprods.php",  'fl=G', 'NONSSL') . '"> G |</A>' .
         '<a href="' . tep_href_link("allprods.php",  'fl=H', 'NONSSL') . '"> H |</A>' .
         '<a href="' . tep_href_link("allprods.php",  'fl=I', 'NONSSL') . '"> I |</A>' .
         '<a href="' . tep_href_link("allprods.php",  'fl=J', 'NONSSL') . '"> J |</A>' .
         '<a href="' . tep_href_link("allprods.php",  'fl=K', 'NONSSL') . '"> K |</A>' .
         '<a href="' . tep_href_link("allprods.php",  'fl=L', 'NONSSL') . '"> L |</A>' .
         '<a href="' . tep_href_link("allprods.php",  'fl=M', 'NONSSL') . '"> M |</A>' .
         '<a href="' . tep_href_link("allprods.php",  'fl=N', 'NONSSL') . '"> N |</A>' .
         '<a href="' . tep_href_link("allprods.php",  'fl=O', 'NONSSL') . '"> O |</A>' .
         '<a href="' . tep_href_link("allprods.php",  'fl=P', 'NONSSL') . '"> P |</A>' .
         '<a href="' . tep_href_link("allprods.php",  'fl=Q', 'NONSSL') . '"> Q |</A>' .
         '<a href="' . tep_href_link("allprods.php",  'fl=R', 'NONSSL') . '"> R |</A>' .
         '<a href="' . tep_href_link("allprods.php",  'fl=S', 'NONSSL') . '"> S |</A>' .
         '<a href="' . tep_href_link("allprods.php",  'fl=T', 'NONSSL') . '"> T |</A>' .
         '<a href="' . tep_href_link("allprods.php",  'fl=U', 'NONSSL') . '"> U |</A>' .
         '<a href="' . tep_href_link("allprods.php",  'fl=V', 'NONSSL') . '"> V |</A>' .
         '<a href="' . tep_href_link("allprods.php",  'fl=W', 'NONSSL') . '"> W |</A>' .
         '<a href="' . tep_href_link("allprods.php",  'fl=X', 'NONSSL') . '"> X |</A>' .
         '<a href="' . tep_href_link("allprods.php",  'fl=Y', 'NONSSL') . '"> Y |</A>' .
         '<a href="' . tep_href_link("allprods.php",  'fl=Z', 'NONSSL') . '"> Z</A>';
         
         echo $firstletter_nav;

 

And your query would look something like this....

 

  $products_new_query_raw = "select p.products_releasedate, p.products_id, pd.products_name, pd.products_description, p.products_image, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id $where order by pd.products_name";

 

Looks pretty straightforward.

-------------------------------------------------------------------------------------------------------------------------

NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit.

If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help.

Link to comment
Share on other sites

Yeah, it can really be put anywhere you want.

 

However, this is just a pretty standard text menu, and for the header you might want something a little better looking, like a dropdown menu or something.

 

In any event, the code I provided should be easy enough to alter to suite your purposes.

-------------------------------------------------------------------------------------------------------------------------

NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit.

If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help.

Link to comment
Share on other sites

  • 3 weeks later...

Ive been looking for this code for ages...

ive searched the foum non stop and now ive finally found the code for it.

 

All i need now is a little help on the files in which the code shld be copied into. im new to this osc thingy.

 

i would like the letters to be placed in Header.

would i need an "all product" contribution?

 

thanks in advance for any help offered.

Link to comment
Share on other sites

the middle part goes wherever you want to display the choices a-z

the first part goes on top of the file that displays the products allprod.php in my case

the last part shows you a modification you have to make to the part in the same file that the search sql for product is made. read the code

Link to comment
Share on other sites

the middle part goes wherever you want to display the choices a-z

the first part  goes on top of the file that displays the products allprod.php in my case

the last part shows you a modification you have to make to the part in the same file that  the search sql for product is made. read the code

 

thank you so much frank... i will give it ago.

you have been a great help.

Link to comment
Share on other sites

right then...

ive done the 1st 2 steps...

they seem to working nice but i cant work out the last bit?

 

ive got my A,B,C links in place and when you click on them they link up nice to the all prods page. the only thing is they dont match the letter. they jus all link to the all prods page.

 

please can someone help me here... i wana get this sorted

Link to comment
Share on other sites

im totally lost on this one so here is my allprods.php file

 

<?php 
/* 
 $Id: allprods.php,v 1.5 2002/09/29 1

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2002 osCommerce

 Released under the GNU General Public License
 
*/ 

  $firstletter=$HTTP_GET_VARS['fl'];
  if (!$HTTP_GET_VARS['page']){
   $where="where p.products_status=1 and pd.products_name like '$firstletter%'";
  }else {
   $where="where p.products_status=1";
  }
 
 require('includes/application_top.php'); 
 include(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ALLPRODS); 

// Set number of columns in listing
define ('NR_COLUMNS', 1);
//
 $breadcrumb->add(HEADING_TITLE, tep_href_link(FILENAME_ALLPRODS, '', 'NONSSL')); 
?> 
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html <?php echo HTML_PARAMS; ?>> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> 
<?php 
// BOF: WebMakers.com Changed: Header Tag Controller v1.0 
// Replaced by header_tags.php 
if ( file_exists(DIR_WS_INCLUDES . 'header_tags.php') ) { 
 require(DIR_WS_INCLUDES . 'header_tags.php'); 
} else { 
?> 
 <title><?php echo TITLE ?></title> 
<?php 
} 
// EOF: WebMakers.com Changed: Header Tag Controller v1.0 
?> 

<base href="<?php echo (getenv('HTTPS') == 'on' ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>"> 
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head> 
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> 
<!-- header //--> 
<?php require(DIR_WS_INCLUDES . 'header.php'); ?> 
<!-- header_eof //--> 

<!-- body //--> 
<table border="0" width="100%" cellspacing="3" cellpadding="3"> 
 <tr> 
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> 
<!-- left_navigation //--> 
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> 
<!-- left_navigation_eof //--> 
   </table></td> 
<!-- body_text //--> 
   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0"> 
     <tr> 
       <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0"> 
         <tr> 
        <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> 
           <td align="right"></td> 
         </tr> 
       </table></td> 
     </tr> 
     <tr> 
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> 
     </tr> 
     <tr> 
       <td> 
       <table border="0" width="100%" cellspacing="0" cellpadding="2"> 
       <tr class="productListing-heading"> 
       <td align="left" class="productListing-heading">Product Name</td> 
      <td align="center" class="productListing-heading">Model</td> 
      <td align="right" class="productListing-heading">Price  </td> 
      </tr> 
            <?php    
            
              
          
            
                            
         $languages_query = tep_db_query("select languages_id, name, code, image, directory from " . TABLE_LANGUAGES . " order by sort_order"); 
         while ($languages = tep_db_fetch_array($languages_query)) { 
           $languages_array[] = array('id' => $languages['languages_id'], 
                                      'name' => $languages['name'], 
                                      'code' => $languages['code'], 
                                      'image' => $languages['image'], 
                                      'directory'   => $languages['directory']); 
         } 
                   for ($i=0; $i<sizeof($languages_array); $i++) 
                   {          
           $this_language_id = $languages_array[$i]['id']; 
           $this_language_name = $languages_array[$i]['name']; 
           $this_language_code = $languages_array[$i]['code']; 
           $this_language_image = $languages_array[$i]['image']; 
           $this_language_directory = $languages_array[$i]['directory']; 
   echo " <tr>\n";
   
   
 

 
 
 
      
         $products_query = tep_db_query("SELECT s.specials_new_products_price, p.products_id, p.products_model, p.products_price, pd.products_name FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd LEFT JOIN " . TABLE_SPECIALS . " s ON p.products_id=s.products_id WHERE p.products_id = pd.products_id AND p.products_status = 1 AND pd.language_id = $this_language_id ORDER BY pd.products_name");
                        
           $products_array = array(); 
           while($products = tep_db_fetch_array($products_query)) 
           { 
              $products_array[] = array('id'=> $products['products_id'], 
                            'name'    => $products['products_name'], 
                            'model'   => $products['products_model'], 
                            'price'   => $products['products_price'], 
                            'tax'     => $products['products_tax_class_id'], 
                            'special' => $products['specials_new_products_price']); 
           } 
            
           $num_prods = sizeof($products_array);  // This optimizes that slow FOR loop... 
            
           for ($i = 0; $i < $num_prods; $i++)    // Traverse Rows 
           { 
              // Rotate Row Colors 
              if ($i % 2)  // Odd Row 
              { 
                 $row_col = 'class="productListing-odd"'; 
              } 
              else   // Guess... 
              { 
                 $row_col = 'class="productListing-even"'; 
              } 
               
     
              $this_id = $products_array[$i]['id']; 
              $this_name = $products_array[$i]['name']; 
              $this_model = $products_array[$i]['model']; 
              $this_price = $products_array[$i]['price']; 
              $this_special = $products_array[$i]['special']; 
              $this_tax = $products_array[$i]['tax']; 
              $this_url = tep_href_link(FILENAME_PRODUCT_INFO,  'name=' . str_replace(" ", "_", $this_name). '&products_id=' . $this_id . (($this_language_code == DEFAULT_LANGUAGE) ? '' : ('&language=' . $this_language_code)), 'NONSSL', false); 

              echo "<tr $row_col>"; 
              echo "<td class='productListing-data' align='left'><a href='$this_url'>$this_name</a></td>"; 
              echo "<td class='productListing-data' align='center'><a href='$this_url'>$this_model</a></td>"; 
              if (tep_not_null($this_special)) 
              { 
                 echo "<td class='productListing-data' align='right'><a href='$this_url'><span class='productSpecialPrice'>".$currencies->display_price($this_special, tep_get_tax_rate($this_tax))."</span></a></td>"; 
              } 
              else 
              { 
                 echo "<td class='productListing-data' align='right'><a href='$this_url'>".$currencies->display_price($this_price, tep_get_tax_rate($this_tax))."</a></td>"; 
              } 
              echo "</tr>\n"; 
           } 
        } 
        
  
?> 
           </td> 
         </tr> 
       </table></td> 
     </tr> 
     <tr> 
   <td align="right" class="main"><br><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT, '', 'NONSSL') . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td> 
     </tr> 
   </table></td> 
<!-- body_text_eof //--> 
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> 
<!-- right_navigation //--> 
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?> 
<!-- right_navigation_eof //--> 
   </table></td> 
 </tr> 
</table> 
<!-- body_eof //--> 

<!-- footer //--> 
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?> 
<!-- footer_eof //--> 
</body> 
</html> 
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

any help from here on in would be amazing.

Link to comment
Share on other sites

  • 6 months later...

LOL, I keep getting replies from people about this months old thread, and I've spotted the issue with my initial post. I'd like to celar it up for people.

 

this $firstletter variable should be this

 

 

$firstletter=$HTTP_GET_VARS['fl'];
  if (!$HTTP_GET_VARS['page']){
   $where="and p.products_status=1 and pd.products_name like '$firstletter%'";
  }else {
   $where="and p.products_status=1";
  }

 

 

and not this

 

$firstletter=$HTTP_GET_VARS['fl'];
  if (!$HTTP_GET_VARS['page']){
   $where="where p.products_status=1 and pd.products_name like '$firstletter%'";
  }else {
   $where="where p.products_status=1";
  }

 

Sorry about the confusion, the initial code was not tested.

-------------------------------------------------------------------------------------------------------------------------

NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit.

If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help.

Link to comment
Share on other sites

  • 5 months later...
Nice one Chris

 

Works like a dream :thumbsup:

 

 

Hi can someone please assist me with this code mentioned above. I have tried to get it working but not sure where i am going wrong. i am able to see the A to Z list and when i click on it nothing happens the page just refreshes as if it is going to that letter..

 

Also to an addition to this is there anyway i can have the a LETTER highlighted before the next alphabet starts.. ie if i click on say D it will go to the letter D and below the products will show.. eg

 

A|B|C|D|E|F|G|H|....etc click D and you see

 

D

Dproduct1

Dproduct2

Dprocduct3

....etcc

 

the code i have is as follows

<?php 
/* 
$Id: azlist.php,v 1.5 2002/09/29 1

osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com

Copyright (c) 2002 osCommerce

Released under the GNU General Public License

*/ 
 $firstletter=$HTTP_GET_VARS['fl'];
 if (!$HTTP_GET_VARS['page']){
  $where="and p.products_status=1 and pd.products_name like '$firstletter%'";
 }else {
  $where="and p.products_status=1";
 }


require('includes/application_top.php'); 
include(DIR_WS_LANGUAGES . $language . '/' . FILENAME_AZLIST); 

// Set number of columns in listing
define ('NR_COLUMNS', 1);
//
$breadcrumb->add(HEADING_TITLE, tep_href_link(FILENAME_AZLIST, '', 'NONSSL')); 
?> 
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html <?php echo HTML_PARAMS; ?>> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> 
<?php 
// BOF: WebMakers.com Changed: Header Tag Controller v1.0 
// Replaced by header_tags.php 
if ( file_exists(DIR_WS_INCLUDES . 'header_tags.php') ) { 
require(DIR_WS_INCLUDES . 'header_tags.php'); 
} else { 
?> 
<title><?php echo TITLE ?></title> 
<?php 
} 
// EOF: WebMakers.com Changed: Header Tag Controller v1.0 
?> 

<base href="<?php echo (getenv('HTTPS') == 'on' ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>"> 
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head> 
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> 
<!-- header //--> 
<?php require(DIR_WS_INCLUDES . 'header.php'); ?> 
<!-- header_eof //--> 

<!-- body //--> 
<table border="0" width="100%" cellspacing="3" cellpadding="3"> 
<tr> 
  <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> 
<!-- left_navigation //--> 
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> 
<!-- left_navigation_eof //--> 
  </table></td> 
<!-- body_text //--> 
  <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0"> 
 <tr> 
   <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0"> 
	 <tr> 
	<td class="pageHeading"><?php echo HEADING_TITLE; ?></td> 
	   <td align="right"></td> 
	 </tr> 
   </table></td> 
 </tr> 
 <tr> 
   <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> 
 </tr> 
 <tr> 
   <td> 
   <table border="0" width="100%" cellspacing="0" cellpadding="2"> 
   <tr class="productListing-heading"> 
   <td align="left" class="productListing-heading">Product Name</td> 
  <td align="center" class="productListing-heading">Model</td> 
  <td align="right" class="productListing-heading">Price  </td> 
  </tr> 
		<?php	


 //pg a to z listing
 $firstletter_nav=
	 '<a href="' . tep_href_link("azlist.php",  'fl=A', 'NONSSL') . '"> A |</A>' . 
	 '<a href="' . tep_href_link("azlist.php",  'fl=B', 'NONSSL') . '"> B |</A>' .
	 '<a href="' . tep_href_link("azlist.php",  'fl=C', 'NONSSL') . '"> C |</A>' .
	 '<a href="' . tep_href_link("azlist.php",  'fl=D', 'NONSSL') . '"> D |</A>' .
	 '<a href="' . tep_href_link("azlist.php",  'fl=E', 'NONSSL') . '"> E |</A>' .
	 '<a href="' . tep_href_link("azlist.php",  'fl=F', 'NONSSL') . '"> F |</A>' .
	 '<a href="' . tep_href_link("azlist.php",  'fl=G', 'NONSSL') . '"> G |</A>' .
	 '<a href="' . tep_href_link("azlist.php",  'fl=H', 'NONSSL') . '"> H |</A>' .
	 '<a href="' . tep_href_link("azlist.php",  'fl=I', 'NONSSL') . '"> I |</A>' .
	 '<a href="' . tep_href_link("azlist.php",  'fl=J', 'NONSSL') . '"> J |</A>' .
	 '<a href="' . tep_href_link("azlist.php",  'fl=K', 'NONSSL') . '"> K |</A>' .
	 '<a href="' . tep_href_link("azlist.php",  'fl=L', 'NONSSL') . '"> L |</A>' .
	 '<a href="' . tep_href_link("azlist.php",  'fl=M', 'NONSSL') . '"> M |</A>' .
	 '<a href="' . tep_href_link("azlist.php",  'fl=N', 'NONSSL') . '"> N |</A>' .
	 '<a href="' . tep_href_link("azlist.php",  'fl=O', 'NONSSL') . '"> O |</A>' .
	 '<a href="' . tep_href_link("azlist.php",  'fl=P', 'NONSSL') . '"> P |</A>' .
	 '<a href="' . tep_href_link("azlist.php",  'fl=Q', 'NONSSL') . '"> Q |</A>' .
	 '<a href="' . tep_href_link("azlist.php",  'fl=R', 'NONSSL') . '"> R |</A>' .
	 '<a href="' . tep_href_link("azlist.php",  'fl=S', 'NONSSL') . '"> S |</A>' .
	 '<a href="' . tep_href_link("azlist.php",  'fl=T', 'NONSSL') . '"> T |</A>' .
	 '<a href="' . tep_href_link("azlist.php",  'fl=U', 'NONSSL') . '"> U |</A>' .
	 '<a href="' . tep_href_link("azlist.php",  'fl=V', 'NONSSL') . '"> V |</A>' .
	 '<a href="' . tep_href_link("azlist.php",  'fl=W', 'NONSSL') . '"> W |</A>' .
	 '<a href="' . tep_href_link("azlist.php",  'fl=X', 'NONSSL') . '"> X |</A>' .
	 '<a href="' . tep_href_link("azlist.php",  'fl=Y', 'NONSSL') . '"> Y |</A>' .
	 '<a href="' . tep_href_link("azlist.php",  'fl=Z', 'NONSSL') . '"> Z</A>';

	 echo $firstletter_nav;

$products_new_query_raw = "select p.products_releasedate, p.products_id, pd.products_name, pd.products_description, p.products_image, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id $where order by pd.products_name";


	 $languages_query = tep_db_query("select languages_id, name, code, image, directory from " . TABLE_LANGUAGES . " order by sort_order"); 
	 while ($languages = tep_db_fetch_array($languages_query)) { 
	   $languages_array[] = array('id' => $languages['languages_id'], 
								  'name' => $languages['name'], 
								  'code' => $languages['code'], 
								  'image' => $languages['image'], 
								  'directory'   => $languages['directory']); 
	 } 
			   for ($i=0; $i<sizeof($languages_array); $i++) 
			   {		  
	   $this_language_id = $languages_array[$i]['id']; 
	   $this_language_name = $languages_array[$i]['name']; 
	   $this_language_code = $languages_array[$i]['code']; 
	   $this_language_image = $languages_array[$i]['image']; 
	   $this_language_directory = $languages_array[$i]['directory']; 
  echo " <tr>\n";








	 $products_query = tep_db_query("SELECT s.specials_new_products_price, p.products_id, p.products_model, p.products_price, pd.products_name FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd LEFT JOIN " . TABLE_SPECIALS . " s ON p.products_id=s.products_id WHERE p.products_id = pd.products_id AND p.products_status = 1 AND pd.language_id = $this_language_id ORDER BY pd.products_name");

	   $products_array = array(); 
	   while($products = tep_db_fetch_array($products_query)) 
	   { 
		  $products_array[] = array('id'=> $products['products_id'], 
						'name'	=> $products['products_name'], 
						'model'   => $products['products_model'], 
						'price'   => $products['products_price'], 
						'tax'	 => $products['products_tax_class_id'], 
						'special' => $products['specials_new_products_price']); 
	   } 

	   $num_prods = sizeof($products_array);  // This optimizes that slow FOR loop... 

	   for ($i = 0; $i < $num_prods; $i++)	// Traverse Rows 
	   { 
		  // Rotate Row Colors 
		  if ($i % 2)  // Odd Row 
		  { 
			 $row_col = 'class="productListing-odd"'; 
		  } 
		  else   // Guess... 
		  { 
			 $row_col = 'class="productListing-even"'; 
		  } 


		  $this_id = $products_array[$i]['id']; 
		  $this_name = $products_array[$i]['name']; 
		  $this_model = $products_array[$i]['model']; 
		  $this_price = $products_array[$i]['price']; 
		  $this_special = $products_array[$i]['special']; 
		  $this_tax = $products_array[$i]['tax']; 
		  $this_url = tep_href_link(FILENAME_PRODUCT_INFO,  'name=' . str_replace(" ", "_", $this_name). '&products_id=' . $this_id . (($this_language_code == DEFAULT_LANGUAGE) ? '' : ('&language=' . $this_language_code)), 'NONSSL', false); 

		  echo "<tr $row_col>"; 
		  echo "<td class='productListing-data' align='left'><a href='$this_url'>$this_name</a></td>"; 
		  echo "<td class='productListing-data' align='center'><a href='$this_url'>$this_model</a></td>"; 
		  if (tep_not_null($this_special)) 
		  { 
			 echo "<td class='productListing-data' align='right'><a href='$this_url'><span class='productSpecialPrice'>".$currencies->display_price($this_special, tep_get_tax_rate($this_tax))."</span></a></td>"; 
		  } 
		  else 
		  { 
			 echo "<td class='productListing-data' align='right'><a href='$this_url'>".$currencies->display_price($this_price, tep_get_tax_rate($this_tax))."</a></td>"; 
		  } 
		  echo "</tr>\n"; 
	   } 
	} 


?> 
	   </td> 
	 </tr> 
   </table></td> 
 </tr> 
 <tr> 
  <td align="right" class="main"><br><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT, '', 'NONSSL') . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td> 
 </tr> 
  </table></td> 
<!-- body_text_eof //--> 
  <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> 
<!-- right_navigation //--> 
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?> 
<!-- right_navigation_eof //--> 
  </table></td> 
</tr> 
</table> 
<!-- body_eof //--> 

<!-- footer //--> 
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?> 
<!-- footer_eof //--> 
</body> 
</html> 
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Link to comment
Share on other sites

  • 3 weeks later...
  • 5 months later...

Archived

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

×
×
  • Create New...