adi123 Posted February 12, 2012 Share Posted February 12, 2012 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> Quote Link to comment https://forums.phpfreaks.com/topic/256958-output-html-in-php/ Share on other sites More sharing options...
Pikachu2000 Posted February 12, 2012 Share Posted February 12, 2012 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; Quote Link to comment https://forums.phpfreaks.com/topic/256958-output-html-in-php/#findComment-1317303 Share on other sites More sharing options...
adi123 Posted February 13, 2012 Author Share Posted February 13, 2012 that didn't work. Is there any other way to do this because the links in the html need to be changed in php to that from the database Quote Link to comment https://forums.phpfreaks.com/topic/256958-output-html-in-php/#findComment-1317603 Share on other sites More sharing options...
adi123 Posted February 13, 2012 Author Share Posted February 13, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/256958-output-html-in-php/#findComment-1317666 Share on other sites More sharing options...
ManiacDan Posted February 13, 2012 Share Posted February 13, 2012 Define "not working." View the source, find the error. Quote Link to comment https://forums.phpfreaks.com/topic/256958-output-html-in-php/#findComment-1317667 Share on other sites More sharing options...
adi123 Posted February 13, 2012 Author Share Posted February 13, 2012 the images display properly in html code but disappear in php output. Quote Link to comment https://forums.phpfreaks.com/topic/256958-output-html-in-php/#findComment-1317673 Share on other sites More sharing options...
ManiacDan Posted February 13, 2012 Share Posted February 13, 2012 And now for the second and third things I said. Quote Link to comment https://forums.phpfreaks.com/topic/256958-output-html-in-php/#findComment-1317684 Share on other sites More sharing options...
adi123 Posted February 13, 2012 Author Share Posted February 13, 2012 Thanks for your replies. I have fixed the problem. It was a sql problem with the pictures column in the database, which wasn't defined properly. my mistake. Works fine now. Quote Link to comment https://forums.phpfreaks.com/topic/256958-output-html-in-php/#findComment-1317701 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.