Page 1 of 1

Nesting PhP tags inside other Php Tags? How to:?

Posted: Thu Dec 22, 2011 11:34 am
by Kylec
Let me start by first saying I am not a PhP coder by any means. That being said, let me state my issue :D

I have a e-commence site that sells products. Buy each product It says "in stock" or "out of stock". I would like a "digital download" link to appear below the in stock or out of stock depending on a value from the database. I have the PhP code working properly to see if there is a value or not. The issue I have is when I try to plug in the php code to the "in stock / out of stock" php code.


"In stock / out of stock" PhP code: (This is just part of the huge code but its the part that deals with the in stock / out of stock section that i need. The opening php tag and closing php tag are there, just not shown)

Code: Select all

$lc_align = 'center';
            if ((STOCK_CHECK == 'true')&&(tep_get_products_stock($listing['products_id']) < 1)) {
	          $lc_text = '<span class="markProductOutOfStock"><b>Out&nbsp;of Stock</b></span>';
            } else {
	          $lc_text = '<span class="markProductInStock"><b>In&nbsp;Stock</b></span>';
            }
            break;

And here's the digital download PhP code: (Each download link is unique to the product so it pulls part of its link from the product)

Code: Select all

<?php if($product_info['products_digital'] != "") { ?>
<A href="https://comics.comixology.com/ret/72/Impulse_Creations_Digital_Store/<?php echo $product_info['products_digital']; ?>" 
target=_blank>Digital Download</A><BR><BR>
<?php } ?>

So I am trying to have the digital download appear right after the in stock and out of stock... any ideas?


Thanks for taking a look,


Kyle

Re: Nesting PhP tags inside other Php Tags? How to:?

Posted: Thu Dec 22, 2011 12:07 pm
by internet-solution
Why do you need nested php tag? You can try something like this -

Code: Select all

$lc_align = 'center';
            if ((STOCK_CHECK == 'true')&&(tep_get_products_stock($listing['products_id']) < 1)) {
                  $lc_text = '<span class="markProductOutOfStock"><b>Out&nbsp;of Stock</b></span>';
            } else 
			{
                  $lc_text = '<span class="markProductInStock"><b>In&nbsp;Stock</b></span>';
					if($product_info['products_digital'] != "")  
						$lc_text .="<A href='https://comics.comixology.com/ret/72/Impulse_Creations_Digital_Store/{$product_info['products_digital']}' target=_blank>Digital Download</A><BR><BR>";
            }
            break;


Re: Nesting PhP tags inside other Php Tags? How to:?

Posted: Thu Dec 22, 2011 1:37 pm
by Kylec
I don't have to put it into php tags if I knew how to correctly merge the two. I tried what you put but nothing showed up :? . I even removed all the stuff after lc_text and just put "test" and nothing still showed up.


Thanks,

Kyle

Re: Nesting PhP tags inside other Php Tags? How to:?

Posted: Thu Dec 22, 2011 3:22 pm
by twinedev
Can you put the code as you have it here.

Re: Nesting PhP tags inside other Php Tags? How to:?

Posted: Fri Dec 23, 2011 12:44 pm
by internet-solution
Kylec wrote:I don't have to put it into php tags if I knew how to correctly merge the two. I tried what you put but nothing showed up :? . I even removed all the stuff after lc_text and just put "test" and nothing still showed up.


Thanks,

Kyle
Can you show your code including database functions. The $product_info array has to be be populated correctly for the code to work as you have this if condition in your code

Code: Select all

if($product_info['products_digital'] != "")