Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

Spot the mistake in this code


Recommended Posts

Hello, I am trying to perform a very simple little modification whereby when in admin panel you select a colour to be added as an attribute, the front end of the site then combines the product name and the product colour to display an image called for example productblue.jpg. This bit I have done with no problems whatsoever.




However, I then want to have these images to be javascript rollovers which when the mouse goes over them display where the main image shows on the page so customers can see a larger picture. As far as I can tell, the code is spot on. No errors reported in ie, firefox or opera, but it just doesn't work. I have been looking at this for hours, and have had 3 or 4 other people look at it, all of whom have told me it should work perfectly. Please somebody put me out of my misery and tell me what I'm doing wrong!!


		//CLR 030714 Add logic for radio buttons
		$tmp_html = '<table>';
		$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$fullurl . "' and pa.options_id = '" . $products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "'");

		$checked = true;
		while ($products_options_array = tep_db_fetch_array($products_options_query)) {
  $attribute_price = $currencies->display_price($products_options_array['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
//tb image replace thingybob
$first = strtolower($products_options_array['products_options_values_name']);
$second = strtolower($product_info['products_name']);
$mystring = "111" . $second . $first . ".jpg222";
$mystring1 = "111" . $second . $first . ".jpg222";
$findme  = '.jpg';
$pos = strpos($mystring, $findme);

$original = array("111", "222");
$bigpic = array("", "");
$replacements = array("<img border=0 width=50 src=Image/", ">");
$start_tags = str_replace($original, $replacements, $mystring);
$big_image = str_replace($original, $bigpic, $mystring1);
$str = strtolower($product_info['products_name']);
$str = strtolower($str);
$stripping_array = array("111", $str, ".jpg222");
$mystring = strtolower($mystring);
$option_name = str_replace($stripping_array, "", $mystring);
$option_name = strtoupper($option_name);
$thingmebob = $start_tags . "<br><center><b>" . $option_name . "</b></center>";

		  $tmp_html .= '<td class="main"><a onMouseOver="document.Ladygrey.src=http://www.mydomain.co.uk/catalog/Image/' .$big_image. '"; onmouseout="document.Ladygrey.src=http://www.mydomain.co.uk/catalog/Image/' . $product_info['products_image'] . '";>';
$tmp_html .= tep_draw_radio_field('id[' . $products_options_name['products_options_id'] . ']', $products_options_array['products_options_values_id'], $checked);
		  $checked = false;
		  $tmp_html .= $thingmebob;
		  $tmp_html .=$products_options_name['products_options_comment'];
		  if ($products_options_array['options_values_price'] != '0') {
			$tmp_html .= '(' . $attribute_price .') ';
		  $tmp_html .= '</a></div></td>';
		$tmp_html .= '</table>';
		  <td class="main"><?php echo $products_options_name['products_options_name'] . ':'; ?></td>
		  <td class="main"><?php echo $tmp_html;  ?></td>


and the main image is displayed as such later in the file:


<table border="0" cellspacing="0" cellpadding="2" align="right">
		  <td align="center" class="smallText">
echo '<div>
 '. tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name']), '', '', 'hspace="0" vspace="0" name="Ladygrey"') . '</div><br>';





and the outputted html on a product called Alice available in black, tan and beige (tan being the default main image) looks like this:


<table border="0" cellspacing="0" cellpadding="2"> <tr> <td class="main" colspan="2">Available Options:</td> </tr> <tr> <td class="main">Color:</td> <td class="main"><table><td class="main"><a onmouseover="document.Ladygrey.src=http://www.mydomain.co.uk/catalog/Image/alicebeige.jpg;" onmouseout="document.Ladygrey.src=http://www.mydomain.co.uk/catalog/Image/alicetan.jpg;"><input type="radio" name="id[1]" value="46" CHECKED><img border=0 width=50 src=Image/alicebeige.jpg><br><center><b>BEIGE</b></center>alicebeige.jpg</a></div></td><td class="main"><a onmouseover="document.Ladygrey.src=http://www.mydomain.co.uk/catalog/Image/alicetan.jpg;" onmouseout="document.Ladygrey.src=http://www.mydomain.co.uk/catalog/Image/alicetan.jpg;"><input type="radio" name="id[1]" value="29"><img border=0 width=50 src=Image/alicetan.jpg><br><center><b>TAN</b></center>alicetan.jpg</a></div></td><td class="main"><a onmouseover="document.Ladygrey.src=http://www.mydomain.co.uk/catalog/Image/aliceblack.jpg;" onmouseout="document.Ladygrey.src=http://www.mydomain.co.uk/catalog/Image/alicetan.jpg;"><input type="radio" name="id[1]" value="28"><img border=0 width=50 src=Image/aliceblack.jpg><br><center><b>BLACK</b></center>aliceblack.jpg</a></div></td></table>

And for the sharp eyed, yes I have changed my images file to Image for varying reasons - this is not the issue!




Please put me out of my misery and point out the obvious (not to me, but hopefully to you) mistake!

Link to comment
Share on other sites


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

  • Create New...