Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

can't get this code to work....


schnauzer

Recommended Posts

i'm trying to put a background image in a table cell and then have the product name print out on top of the background image.

 

Here's how I've unsuccessfully tried to code it :

 

<table cellspacing=0 cellpadding=0>
		   <tr><td background="images/m48.gif" width=537 height=36><class=ml2><b><?=$products_name?></b></td></tr>
		   <tr><td height=3></td></tr>
			</table>

Link to comment
Share on other sites

try this:

<table cellspacing="0" cellpadding="0">
<tr><td background="images/m48.gif" width=537 height=36><b><?php echo $products_name; ?></b></td></tr>
<tr><td height="3"></td></tr>
</table>

 

and make sure the $products_name variable is populated with a string or something.

Link to comment
Share on other sites

try this:

<table cellspacing="0" cellpadding="0">
<tr><td background="images/m48.gif" width=537 height=36><b><?php echo $products_name; ?></b></td></tr>
<tr><td height="3"></td></tr>
</table>

 

and make sure the $products_name variable is populated with a string or something.

 

 

Nope... still no name. The background picture and everything else comes up except for the name. I'm using this command to call up the name elsewhere on the page:

 

[/code]

<tr><td class=ml2><b><?=$products_name?></b></td></tr>

I guess means the string is ok so why can't I get it to come up above the background image? Any other thoughts??

Link to comment
Share on other sites

Lose the CSS class and see if it shows then.

 

In your original post you called your style as <class=ml2><b><?=$products_name?></b>

 

If you defined that style as td.ml2 you should call it as <td class="ml2">

 

Or if you defined it as .ml2, then try using

<span class="ml2"><?=$products_name?></span>

Link to comment
Share on other sites

Still not working. It's defined as .ml2 so here's how I wrote it out...

 

<table cellspacing=0 cellpadding=0>
<tr><td background="images/m48.gif" width=537 height=36><span class="ml2"><?=$products_name?></span></td></tr>
<tr><td height=3></td></tr>
<tr><td><img src=images/m50.gif width=537 height=5></td></tr>
</table>

 

Is it possible the product is appearing behind the image so that's why I can't see it? Any more thoughts??

Link to comment
Share on other sites

Could be, kill the background image and you will see.

 

If that is the case or even if it isn't, try re-defining your stylesheet to something like:

 

td.ml2 {

font-family: Verdana, Arial, Helvetica, sans-serif;

font-size: 0.7em;

font-weight: bold;

color:#000;

background-image:

url('images/m48.gif');

}

 

<td class="ml2"> </td>

Link to comment
Share on other sites

It's not showing behind the pic I checked that out. Still can't make it work. I've tried it so many different ways that I can't believe I didn't get it purely by accident.

 

There has to be something I'm overlooking, especially since this code is making the product name appear lower on the page:

 

td width=268 valign=top>

<table cellspacing=0 cellpadding=0>

<tr><td height=21></td></tr>

<tr><td class=ml2><b><?=$products_name?></b></td></tr>

<tr><td height=4></td></tr>

<tr><td><img src=images/m49.gif width=265 height=1></td></tr>

<tr><td height=10></td></tr>

<tr><td>

<table>

 

What else can you think of???

Link to comment
Share on other sites

It's going to be something simple, like a syntax error maybe or what about the text color being the same color as the background image. :blink:

 

Ok, unlikely I know, but what about pasting your CSS code here, cos maybe you can't see the wood for the trees.

Link to comment
Share on other sites

Here's my entire products_info.php code. I changed the class to .m14 and moved as much of it to the stylesheet as i could. I left alot of spaces on either side of the offending area:

 

<?php
/*
 $Id: product_info.php,v 1.97 2003/07/01 14:34:54 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCT_INFO);

 $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);
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<?php
// BOF: WebMakers.com Changed: Header Tag Controller v2.5.2
// 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 v2.5.2
?>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<script language="javascript"><!--
function popupWindow(url) {
 window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,res
izable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,le
ft=150')
}
//--></script>
</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="0" cellpadding="0">
 <tr>
<!-- body_text //-->
<td width="100%" valign="top"><?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product')); ?>





table cellspacing=0 cellpadding=0>
<tr><td class=ml4><b><?php echo $products_name; ?></b></td></tr>
<tr><td height=3></td></tr>
<tr><td><img src=images/m50.gif width=537 height=5></td></tr>
</table>






<table border="0" width="100%" cellspacing="0" cellpadding="0">
<?php
 if ($product_check['total'] < 1) {
?>	

  <tr>
	<td><?php new infoBox(array(array('text' => TEXT_PRODUCT_NOT_FOUND))); ?></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
  <tr>
	<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
	  <tr class="infoBoxContents">
		<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			<td align="right"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		  </tr>
		</table></td>
	  </tr>
	</table></td>
  </tr>
<?php
 } else {
// Big Image Amended Line
// $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, 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 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_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, p.products_mediumimage, p.products_largeimage, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id 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);

tep_db_query("update " . TABLE_PRODUCTS_DESCRIPTION . " set products_viewed = products_viewed+1 where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and language_id = '" . (int)$languages_id . "'");

if ($new_price = tep_get_products_special_price($product_info['products_id'])) {
  $products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>';
} else {
  $products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
}

if (tep_not_null($product_info['products_model'])) {
  $products_name = $product_info['products_name'] . '<br><span class="smallText">[' . $product_info['products_model'] . ']</span>';
} else {
  $products_name = $product_info['products_name'];
}
?>

		   <tr><td>
		  <table cellspacing=0 cellpadding=0>

		   <tr><td width=537 class=bg3>
		   <table cellspacing=0 cellpadding=0>
			 <tr><td width=252 align=center valign=middle>


<!-- display image -->
<?php
if (tep_not_null($product_info['products_image'])) {
?>
	  <table cellspacing="0" cellpadding="2" align="center">
		<tr>
		  <td align="center" class="smallText">
<script language="javascript"><!--
document.write('<?php echo '<a href="javascript:popupWindow(\\\'' . tep_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $product_info['products_id']) . '\\\')">' . tep_image(DIR_WS_IMAGES . $product_info['products_mediumimage'], addslashes($product_info['products_name']), MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>');
//--></script>
<noscript>
<?php echo '<a href="' . tep_href_link(DIR_WS_IMAGES . $product_info['products_mediumimage']) . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $product_info['products_mediumimage'], $product_info['products_name'], MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>
</noscript>
		  </td>
		</tr>
	  </table>
<?php
}
?>
<!--end display image -->

		   </td>


				<td width=268 valign=top>
				 <table cellspacing=0 cellpadding=0>
				  <tr><td height=21></td></tr>
				  <tr><td class=ml2><b><?=$products_name?></b></td></tr>
				  <tr><td height=4></td></tr>
				  <tr><td><img src=images/m49.gif width=265 height=1></td></tr>
				  <tr><td height=10></td></tr>
				  <tr><td>
					<table>
			 <tr><td><b>Item price:?<font color="#FF0000"> <?php echo $products_price; ?></font></b></td></tr>
	 <tr><td>
			</table>  



<?php
$products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'");
$products_attributes = tep_db_fetch_array($products_attributes_query);
if ($products_attributes['total'] > 0) {
?>
	  <table border="0" cellspacing="0" cellpadding="2">
		<tr>
		  <td class="main" colspan="2"><?php echo TEXT_PRODUCT_OPTIONS; ?></td>
		</tr>
<?php
  $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_name");
  while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
	$products_options_array = array();
	$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)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'");
	while ($products_options = tep_db_fetch_array($products_options_query)) {
	  $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);
	  if ($products_options['options_values_price'] != '0') {
		$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
	  }
	}

	if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) {
	  $selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']];
	} else {
	  $selected_attribute = false;
	}
?>
		<tr>
		  <td class="main"><?php echo $products_options_name['products_options_name'] . ':'; ?></td>
		  <td class="main"><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?></td>
		</tr>
<?php
  }
?>
	  </table>



				 </td></tr>
				  <tr><td height=10></td></tr>
				  <tr><td><b>Item # :</b> <?= $products_id; ?></td></tr>
				  <tr><td height=10></td></tr>
				  <tr><td></td></tr>
				  <tr><td height=10></td></tr>
				  <tr><td><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_BUY_NOW); ?></td></tr>								
				 </table>
				</td>
				<td width=17></td></tr>
			 <tr><td height=15 colspan=3></td></tr>
			 <tr><td colspan=3>
				 <table cellspacing=0 cellpadding=0 width=508 align=center>
				  <tr><td><b>Item Description</b></td></tr>
<tr><td><img src=images/m49.gif width=265 height=1></td></tr>
<tr><td>
				  <tr><td height=5></td></tr>  
				  <tr><td><?php echo stripslashes($product_info['products_description']); ?><br><br></td></tr>
				 </table>
			 </td></tr>
			</table>
		   </td></tr>
		   <tr><td><img src=images/m52.gif width=537 height=6></td></tr>	   
		  </table>
		</td></tr>



<!----------------------- Not editable part -------------------------------->

  <tr><td>

<?php
}
?>
	</td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
<?php
$reviews_query = tep_db_query("select count(*) as count from " . TABLE_REVIEWS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
$reviews = tep_db_fetch_array($reviews_query);
if ($reviews['count'] > 0) {
?>
  <tr>
	<td class="main"><?php echo TEXT_CURRENT_REVIEWS . ' ' . $reviews['count']; ?></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
<?php
}

if (tep_not_null($product_info['products_url'])) {
?>
  <tr>
	<td class="main"><?php echo sprintf(TEXT_MORE_INFORMATION, tep_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($product_info['products_url']), 'NONSSL', true, false)); ?></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
<?php
}

?>
<!--
  <tr>
	<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
	  <tr class="infoBoxContents">
		<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			<td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params()) . '">' . tep_image_button('button_reviews.gif', IMAGE_BUTTON_REVIEWS) . '</a>'; ?></td>
			<td class="main" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		  </tr>
		</table></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
-->
  <tr>
	<td>
<?php
/*
if ((USE_CACHE == 'true') && empty($SID)) {
  echo tep_cache_also_purchased(3600);
} else {
  include(DIR_WS_MODULES . FILENAME_ALSO_PURCHASED_PRODUCTS);
}
*/
 }
?>


  </td></tr>

</table>
</form></td>
<!-- body_text_eof //-->
 </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

There is a < missing from table>

 

 

Good eye! But no, it's in there. I must have accidentally deleted it in the enclosed code when I was created the extra spaces. This is really hanging me up. :angry:

Link to comment
Share on other sites

Does the product it is looking for exist? Are you seeing Product not found!?

 

 

The way I'm testing it is by loading product pages to see if the title appears...so yeah there are products in there.

Link to comment
Share on other sites

I'm no PHP expert so I'm not sure how that works, by echoing the $products_name variable. However, one thing I noticed before, when you posted your code, you said it was for products_info.php. The file is actually product_info.php, singular. Being as you are using the file names, is it possible you have mistyped somewhere?

 

That is probably too simple to be true, but we're running short on ideas here, so worth checking.

Link to comment
Share on other sites

I'm no PHP expert so I'm not sure how that works, by echoing the $products_name variable. However, one thing I noticed before, when you posted your code, you said it was for products_info.php. The file is actually product_info.php, singular. Being as you are using the file names, is it possible you have mistyped somewhere?

 

That is probably too simple to be true, but we're running short on ideas here, so worth checking.

 

 

Nah that wasn't it...I gave up. I'll just have to leave the name out of where I was trying to put it.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...