darkfreaks Posted June 20, 2012 Share Posted June 20, 2012 <img src="../path/to/folder/<? echo $id; ?>/<? echo $image[0]; ?>" /> this seems abit sloppy to me hmmm..... Link to comment https://forums.phpfreaks.com/topic/264477-better-way-of-putting-php-inside-img-tag/ Share on other sites More sharing options...
Barand Posted June 20, 2012 Share Posted June 20, 2012 <?php echo "<img src='../path/to/folder/$id/{$image[0]}' />"; ?> Link to comment https://forums.phpfreaks.com/topic/264477-better-way-of-putting-php-inside-img-tag/#findComment-1355417 Share on other sites More sharing options...
onlyican Posted June 20, 2012 Share Posted June 20, 2012 I tend to use PHP insdie a tag, but I wouldn't escape out of PHP just for a slash <img src="/dir/<?php echo $id .'/'. $image[0];?>" /> Link to comment https://forums.phpfreaks.com/topic/264477-better-way-of-putting-php-inside-img-tag/#findComment-1355421 Share on other sites More sharing options...
darkfreaks Posted June 20, 2012 Author Share Posted June 20, 2012 got another problem i tried to rewrite it inside an echo like barand suggested getting errrors <? echo"<td><a href="" onClick="MM_swapImage('Limage','','../cms/models/content/'.$modelID.'/'{.$image[3].}'',1)"> <img src='../cms/models/content/".$modelID."/"{.$image[3].}"' width="70" height="116" border="0"></a></td>"; ?> Link to comment https://forums.phpfreaks.com/topic/264477-better-way-of-putting-php-inside-img-tag/#findComment-1355580 Share on other sites More sharing options...
Barand Posted June 20, 2012 Share Posted June 20, 2012 You are trying to use " inside a string already enclosed by ""s. Either escape them (\") or substitute single quotes eg <?php echo"<td><a href='' onClick=\"MM_swapImage('Limage','','../cms/models/content/$modelID/{$image[3]}',1)\"> <img src='../cms/models/content/$modelID/{$image[3]}' width='70' height='116' border='0'></a></td>"; ?> Link to comment https://forums.phpfreaks.com/topic/264477-better-way-of-putting-php-inside-img-tag/#findComment-1355588 Share on other sites More sharing options...
darkfreaks Posted June 20, 2012 Author Share Posted June 20, 2012 works now but i am getting a broken image hmmm Link to comment https://forums.phpfreaks.com/topic/264477-better-way-of-putting-php-inside-img-tag/#findComment-1355590 Share on other sites More sharing options...
darkfreaks Posted June 20, 2012 Author Share Posted June 20, 2012 how would i escape a body onload swap function? that is the only thing left to fix now. Link to comment https://forums.phpfreaks.com/topic/264477-better-way-of-putting-php-inside-img-tag/#findComment-1355617 Share on other sites More sharing options...
ZulfadlyAshBurn Posted June 21, 2012 Share Posted June 21, 2012 what do you mean body onload swap function? Link to comment https://forums.phpfreaks.com/topic/264477-better-way-of-putting-php-inside-img-tag/#findComment-1355715 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.