Forum Moderators: coopster

Message Too Old, No Replies

trying to add a new line in php - please help

         

marcus76

11:18 am on May 1, 2006 (gmt 0)

10+ Year Member



Hi ,

I have the following line of code:

$cart_contents_string .= $products[$i]['quantity'] . '&nbsp;x&nbsp; </span></td><td valign="top" class="ShoppingCartBoxContents"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"> ' ;

i'd like to add this to it:

tep_image(DIR_WS_IMAGES . $products[$i]['image'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT)

The output displays the image, then to the right (next column) the product name, and at the bottom of the image to the right , the quantity.

I'd like to display:

Product name
Product quantity
Product image

all in a single column, one after each other.

Any ideas where i need to place the 2nd line of code? i think i need a new line before i display the image -but how?

Many thanks

Marc

coopster

11:22 am on May 1, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



newlines only work when you echo a newline within preformatted html elements, something like this:
<?php 
print "<pre>Line 1\nLine 2\nLine 3\n</pre>";
?>

The other way to get line breaks is to use the proper HTML such as <p> elements or <br /> elements in between each.

marcus76

11:52 am on May 1, 2006 (gmt 0)

10+ Year Member



thanks coopster, i cannot add any of those to my line of code though right?

coopster

11:44 pm on May 1, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Not sure what you are asking. If it is within the table cell you should just be able to use a <br> element.

hakre

10:18 am on May 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



or let php do the <br>ing work for you: nl2br() [php.net] converts each linebreak into the according html tag so you do not need to care about any longer. it even matches up with xhtml in case you need.

--hakre

marcus76

11:28 am on May 2, 2006 (gmt 0)

10+ Year Member



ok, so how does this look?

$cart_contents_string .= tep_image(DIR_WS_IMAGES . nl2br() . $products[$i]['image'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . $products[$i]['quantity'] . '&nbsp;x&nbsp; </span></td><td valign="top" class="ShoppingCartBoxContents"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"> ' ;

I can't try it until this evening, but i'm hoping for the following display in 1 column.

IMAGE <br>
Quantity , Product id

Cheers

Marcus