Jump to content

output html in php


adi123

Recommended Posts

I am trying to output the following html code in php using echo, but it won't display properly. Can someone help me echo the following lines please, already spend a few days on it.

 

 

 


    <div class="product_box margin_r40">
    <div class="image_wrapper">       
        <a href="../shops/adysshop/items/IMG_6724.JPG" class="jqzoom" rel='gal1'  title="Product Preview" >
            <img src="../shops/adysshop/items/IMG_6724_small.jpg"  title="triumph"  style="border: 4px solid #666;">
        </a>
    </div>
<br/>
    <p> </p>
<div class="clearfix" >
<ul id="thumblist" class="clearfix" >
	<li><a class="zoomThumbActive" href='javascript:void(0);' rel="{gallery: 'gal1', smallimage: '../shops/adysshop/items/IMG_6724_small.jpg',largeimage: '../shops/adysshop/items/IMG_6724.JPG'}"><img src='../shops/adysshop/items/IMG_6724_thumb.jpg'></a></li>
	<li><a href='javascript:void(0);' rel="{gallery: 'gal1', smallimage: './imgProd/IMG_6972_small.jpg',largeimage: './imgProd/IMG_6972.JPG'}"><img src='imgProd/thumbs/IMG_6972_thumb.jpg'></a></li>
	<li><a  href='javascript:void(0);' rel="{gallery: 'gal1', smallimage: './imgProd/IMG_6900_small.jpg',largeimage: './imgProd/IMG_6900.JPG'}"><img src='imgProd/thumbs/IMG_6900_thumb.jpg'></a></li>
</ul>
</div>
</div>

Link to comment
https://forums.phpfreaks.com/topic/256958-output-html-in-php/
Share on other sites

It would be easiest to simply drop out of php when you need to output that, but if for some reason you absolutely must use php to echo it, HEREDOC syntax would be the least problematic way to do it. Be sure to read the manual entry in the link; there is a specific way to use that syntax.

 

$output = <<<HERE
    <div class="product_box margin_r40">
    <div class="image_wrapper">
        <a href="../shops/adysshop/items/IMG_6724.JPG" class="jqzoom" rel='gal1'  title="Product Preview" >
            <img src="../shops/adysshop/items/IMG_6724_small.jpg"  title="triumph"  style="border: 4px solid #666;">
        </a>
    </div>
    <br/>
    <p> </p>
<div class="clearfix" >
    <ul id="thumblist" class="clearfix" >
        <li><a class="zoomThumbActive" href='javascript:void(0);' rel="{gallery: 'gal1', smallimage: '../shops/adysshop/items/IMG_6724_small.jpg',largeimage: '../shops/adysshop/items/IMG_6724.JPG'}"><img src='../shops/adysshop/items/IMG_6724_thumb.jpg'></a></li>
        <li><a href='javascript:void(0);' rel="{gallery: 'gal1', smallimage: './imgProd/IMG_6972_small.jpg',largeimage: './imgProd/IMG_6972.JPG'}"><img src='imgProd/thumbs/IMG_6972_thumb.jpg'></a></li>
        <li><a  href='javascript:void(0);' rel="{gallery: 'gal1', smallimage: './imgProd/IMG_6900_small.jpg',largeimage: './imgProd/IMG_6900.JPG'}"><img src='imgProd/thumbs/IMG_6900_thumb.jpg'></a></li>
    </ul>
    </div>
</div>
HERE;

echo $output;

Link to comment
https://forums.phpfreaks.com/topic/256958-output-html-in-php/#findComment-1317303
Share on other sites

The html works fine but the php doesn't display properly. here's the difference.

 

 

HTML

 


    <div class="product_box margin_r40">
    <div class="image_wrapper">     
        <a href="../shops/adysshop/items/IMG_6724.JPG" class="jqzoom" rel='gal1'  title="Product Preview" >
            <img src="../shops/adysshop/items/IMG_6724_small.jpg"  title="triumph"  style="border: 4px solid #666;">
        </a>
    </div>
<br/>
    <p> </p>
<div class="clearfix" >
<ul id="thumblist" class="clearfix" >
	<li><a class="zoomThumbActive" href='javascript:void(0);' rel="{gallery: 'gal1', smallimage: '../shops/adysshop/items/IMG_6724_small.jpg',largeimage: '../shops/adysshop/items/IMG_6724.JPG'}"><img src='../shops/adysshop/items/IMG_6724_thumb.jpg'></a></li>
	<li><a href='javascript:void(0);' rel="{gallery: 'gal1', smallimage: './imgProd/IMG_6972_small.jpg',largeimage: './imgProd/IMG_6972.JPG'}"><img src='imgProd/thumbs/IMG_6972_thumb.jpg'></a></li>
	<li><a  href='javascript:void(0);' rel="{gallery: 'gal1', smallimage: './imgProd/IMG_6900_small.jpg',largeimage: './imgProd/IMG_6900.JPG'}"><img src='imgProd/thumbs/IMG_6900_thumb.jpg'></a></li>
</ul>
</div>
</div>

 

 

PHP

 


	echo '<div class="product_box margin_r40">';
	echo '<div class="image_wrapper">';
	echo '<a href="../shops/'.$row['s_page'].'/items/'.$row['pic'].'" class="jqzoom" rel="gal1"  title="Product Preview"><img src="../shops/'.$row['s_page'].'/items/'.$row['pic_small'].'" title="triumph" style="border: 4px solid #666;"></a>';
	echo '</div>';
	echo '<br/>';
	echo '<p> </p>';
	echo ' <div class="clearfix" >';
	echo '<ul id="thumblist" class="clearfix" >';
	echo '<li><a class="zoomThumbActive" href="javascript:void(0);" rel={gallery: "gal1", smallimage: "../shops/adysshop/items/IMG_6724_small.jpg",largeimage: "../shops/adysshop/items/IMG_6724.JPG"}><img src="../shops/adysshop/items/IMG_6724_thumb.jpg"></a></li>';
	echo '<li><a href="javascript:void(0);" rel={gallery: "gal1", smallimage: "./imgProd/IMG_6972_small.jpg",largeimage: "./imgProd/IMG_6972.JPG"}><img src="imgProd/thumbs/IMG_6972_thumb.jpg"></a></li>';
	echo '<li><a  href="javascript:void(0);" rel={gallery: "gal1", smallimage: "./imgProd/IMG_6900_small.jpg",largeimage: "./imgProd/IMG_6900.JPG"}><img src="imgProd/thumbs/IMG_6900_thumb.jpg"></a></li>';
	echo '</ul>';
	echo '</div>';
	echo '</div>';

 

It looks about right so why is it not working.

Link to comment
https://forums.phpfreaks.com/topic/256958-output-html-in-php/#findComment-1317666
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.