Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

A minor PHP problem that I should be able to solve...


ComicWisdom

Recommended Posts

I am using graphics (letters of the alphabet mineral specimens) for my categories list. However, at the end, there is one catch-all category for miscellaneous items. I am trying to make the category loop stop when the "Z" graphic is displayed (#26). I managed to get it to move to the next line after the "M" graphic (#13) is displayed, but I can't get it to stop at the "Z".

 

Here is a link to the page and the code with my lame attempts (noted) included.

 

Could someone give me a hand with this?

 

 

http://tmm1.netkraftershowroom.com/catalog/index.php

 

 

  function tep_show_category($counter) {
global $tree, $categories_string, $cPath_array;

for ($i=0; $i<$tree[$counter]['level']; $i++) {
  #declare a
  $altVar = "";
  $categories_string .= "<span class=\"subNav\">";
}

$categories_string .= '<a href="';

if ($tree[$counter]['parent'] == 0) {
  $cPath_new = 'cPath=' . $counter;
  $getCpath = $_GET['cPath'];
	# regular expression returns the main category number from the subcategory string:
	$match = eregi_replace("^([0-9]{1,2})(_[0-9]{2})$",'\\1',$getCpath);
	# if category is selected, just write out an ordinary <a> tag:
	if ($counter == $match)	{
		$categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">';
	} else	{
		# else cateogry is not selected, so write out the <a> tag with the mouse events:
		$categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '" onmouseover="chgImg(\'nav' . $counter . '\',\'nav' . $counter . '_over\')" onmouseout="chgImg(\'nav'. $counter .'\',\'nav'. $counter .'\')">';
	}
} else {
  $cPath_new = 'cPath=' . $tree[$counter]['path'];
  # otherwise (if a subcategory) just write out a plain <a> tag
  $categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">';
}

// display category name
# if top level category, use an image:
if ($tree[$counter]['parent'] == 0) {
	# if category is selcted, write out the '_over' version of the gif:
	if ($counter == $match)	{
		$categories_string .= '<img src="images/navigation/nav' . $counter . '_over.jpg" width="40" height="40" border="0" name="nav' . $counter . '" alt="' . $altVar = $tree[$counter]['name'] . '" title="' . $altVar = $tree[$counter]['name'] . '">';
			if ($counter == 13) {
			   $categories_string .= '<br>';
			  }
[b]//my first part of attempt that didn't work[/b]
			 if ($counter == 26) {
			   $counter == 27;
			   $i == 27;
			   }
		  } else	{
		# else just write out the 'off' version:
		$categories_string .= '<img src="images/navigation/nav' . $counter . '.jpg" width="40" height="40" border="0" name="nav' . $counter . '" alt="' . $altVar = $tree[$counter]['name'] . '" title="' . $altVar = $tree[$counter]['name'] . '" "' . '">';
		if ($counter == 13) {
			   $categories_string .= '<br>';
			   }
[b]//my second part of attempt that didn't work[/b]
			 if ($counter == 26) {
			   $counter == 27;
			   $i = 27;
			   }
			 }
	}

Just between us, remember there are only 10 kinds of people in the world; those who understand binary and those who don't!!

 

Remember, learning is a "do-it-yourself" experience; although, not necessarily a "do-it-BY-yourself" experience.

 

The quickest way to learn is to forget to BACKUP!

Link to comment
Share on other sites

I don't know if it will fix your problem but on a quick glance, these

 $counter == 27;
$i == 27;
$counter == 27;

should be

$counter = 27;
$i = 27;
$counter = 27;

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Thank you for your help, Jack.

 

The double == in the second half of each if statement was definitly part of the problem. The solution that worked is this:

 

if ($counter == 26) {
			   $counter = 27;
   }

Just between us, remember there are only 10 kinds of people in the world; those who understand binary and those who don't!!

 

Remember, learning is a "do-it-yourself" experience; although, not necessarily a "do-it-BY-yourself" experience.

 

The quickest way to learn is to forget to BACKUP!

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...