Coded Firstimage Coded Firstimage - 23 days ago 7
PHP Question

How do i echo variable inside html

I have an html image blackgroud code wish i like to output $cartTotal result in it my problem is how do i echo variable $cartTotal inside the html code i have tried:

<?php echo'<TABLE BORDER="0" cellpadding="0" CELLSPACING="0"> <TR> <TD WIDTH="60" HEIGHT="70" BACKGROUND="inventory_images/3.jpg" VALIGN="bottom"> <FONT SIZE="+5" COLOR="red"><?php
echo "$cartTotal";
?></FONT></TD> </TR> </TABLE>'; ?>


but it return $cartTotal instade of $cartTotal result

Answer Source

Don't write PHP inside PHP. change your code to:

<?php echo'<TABLE BORDER="0" cellpadding="0" CELLSPACING="0"> <TR> <TD WIDTH="60"
 HEIGHT="70" BACKGROUND="inventory_images/3.jpg" VALIGN="bottom"> <FONT SIZE="+5" 
COLOR="red">'.$cartTotal.'</FONT></TD> </TR> </TABLE>'; ?>