I have the following code working in another document
<img src="<?php echo $option_upload_url . '/' . $shortname . '_banner1_imagen.'.$get_banner1_imagen_ext; ?>" alt="<?php bloginfo('name'); ?>" Style="width:100%" />
but now i took to next expression:
echo "<img src=\"$option_upload_url/$shortname_banner1_imagen$get_banner1_imagen_ext\" >";
but seems like the parth isnt correctly implemented, tried diferent things i found on the web but couldnt manage to find a solution...
EDIT:
The image isnt loading when i use the second code.
Try it like this, php isn't understanding which are your variable names, and you forgot the . between _imagen and $get_banner1_imagen_ext
echo "<a href=\"".stripcslashes($get_ads_code_one)."\" title=\"".bloginfo('name')."\">
<img src=\"$option_upload_url/{$shortname}_banner1_imagen.{$get_banner1_imagen_ext}\" /></a>";
I would prefer going with the single ' at the place of escaping ", keep " in the html like this:
echo '<a href="'.stripcslashes($get_ads_code_one).'" title="'.bloginfo('name').'">
<img src="'.$option_upload_url.'/'.$shortname.'_banner1_imagen.'.$get_banner1_imagen_ext.'" /></a>';
You need to have your PHP variables be outside the quotes for them to not be taken as literals.
echo "<img src='" . $option_upload_url . "/" . $shortname_banner1_imagen . $get_banner1_imagen_ext . "' >";
Related
Hey guys got a question on outputting a dynamic PHP block for a dynamically created PHP page. In my code I am looking for a string in an HTML page thats been uploaded. Once found I am replacing the string with a block of PHP code, the HTML page will be saved as a PHP page to be used on the project. So as I am looping through the HTML I am replacing the string with this ($i is replaced with the number in the loop so I can use them in my array.)
$phpCodeNoLink = '<span id="Title'.$i.'"><?php echo $sl_result['.$i.'][2]; ?></span>
<a href="editor.php?<?php echo "vfSID=" . $sl_result['.$i.'][0] . "&vfSection=2&vfSLink=" . $sl_result['.$i.'][4] . "&vfOrderID=" . $sl_result['.$i.'][5] . "&vfID=" . $vfID; ?>" target="_parent">
<img src="images/btn_edit.gif" border="0" id="SL_editButton'.$i.'" class="editButton" />
</a>';
The problem is it is not outputting what I need, example of what it should look like
<span id="Title1"><?php echo $sl_result[1][2]; ?></span>
<a href="editor.php?<?php echo "vfSID=" . $sl_result[1][0] . "&vfSection=2&vfSLink=" . $sl_result[1][4] . "&vfOrderID=" . $sl_result[1][5] . "&vfID=" . $vfID; ?>" target="_parent">
<img src="images/btn_edit.gif" border="0" id="SL_editButton1" class="editButton" />
</a>
This is what I get in the PHP page once it's generated
<span id="Title0"><?php echo $sl_result[0][2]; ?></span>
<a href="editor.php?<?php%20echo%20%20" vfsid=" . $sl_result[0][0] . " .>" target="_parent">
<img src="images/btn_edit.gif" border="0" class="editButton"></a>
The PHP tags are being replaced and I am missing a whole block of code. Am I missing something any help would be much appreciated.
Figured it out, the PHP code was being parsed and removed by my inline CSS converter moving it above all the other parsing resolved it issue...
I am creating a table using both Bootstrap and PHP, which makes use of Popovers. I would ideally like my popover to include a JPG but as I am already using echo to create my html table I am unsure how to incorporate it. I have tried to include the usual 'img src' as shown below but it's just printing out the code.
echo "<td colspan='$newlength' id='example' rel='popover' data-content='<img src='imagetouse.jpg' /> This is my content.' data-title=' This is my Title'>$name . $time2</td>";
The above code terminates the tags after the image src. I am unable to use "" around my image because they surround the whole tags for the echo therefore again terminating the code.
Having attempted nietonfir's suggestion:
echo '<td colspan="' . $newlength . '" id="example" rel="popover" data-content="<img src=\'imagetouse.jpg\' /> This is my content." data-title="This is my Title">' . $name . $time2 . '</td>';
The content of my popover now reads as opposed to displaying the image:
<img src='imagetouse.jpg' /> This is my content.
For one I think that you should move the image to the content attribute. And I couldn't find a description to "original-title", so I assume you just meant title. According to the documentation you can insert HTML into the popover by setting an attribute. See this jsBin for a demo.
<div id="foo" data-html="true" data-content="<img src='http://placehold.it/200x100' /> Content" data-title="Title!">Click</div>
[edit]
Concerning your wrong output statement, the following snippet might fix your issue (please be aware that I didn't incorporate the necessary data-html="true" change for the popover to work):
echo '<td colspan="' . $newlength . '" id="example" rel="popover" data-content="<img src=\'imagetouse.jpg\' /> This is my content." data-title="This is my Title">' . $name . $time2 . '</td>';
Imho you should always terminate your strings and concatenate them. In the case of DOM output I'd even terminate the parser and output the variables individually like
?>
<td colspan="<?php echo $newlength; ?>" id="example" rel="popover" data-content="<img src='imagetouse.jpg' /> This is my content." data-title="This is my Title"><?php echo $name . $time2;?></td>
This way it is easier to spot mistakes for one. And on the other side your editor can highlight your code as what it is: HTML.
I have the following line:
<td><img src="Photos/<? echo $rows['photo1']; ?>" height="200" /></td>
I don't always have a photo. I would like to hide the image space. It looks like it is broken or if the url is wrong.
<td><?php echo (!empty($rows['photo1']) ? '<img src="Photos/' . $rows['photo1'] . '" height="200" />' : '') ?></td>
To have no <img> tag appear for blank values, I'd use something like this:
<?php if (($rows['photo1'] !== "") || ($row['photo1']))
{
echo "<td><img src='Photos/" . $rows['photo1'] . "' height='200' /></td>";
}
?>
if (image is not blank, and it exists) {
then, echo the img tag and the variables
}
Alternatively, If you want to display a different image for blank values:
<td>
<img src="Photos/<?php if ($rows['photo1'] !== ""){echo $rows['photo1'];}
else {echo "defaultimg.jpg";}?>" height="200" />
</td>
Hope this helps :)
Perhaps this is more to your liking:
<img src="Photos/<? echo $rows['photo1']; ?>" height="200" onerror="this.style.display='none'" />
It sets the image to not show when there is a problem (such as a broken URL).
This has the advantage of avoiding ternaries, separates PHP from HTML, and keeps things clear without excessive documentation. Hope it helps.
Hi I tried to echo a image (as a part of an if/else code), but I couldn't really do it.
Here's my code:
echo "<a href="<?php the_permalink() ?>" rel="bookmark" ><img src="<?php bloginfo( 'template_directory' ); ?>/timthumb.php?src=<?php echo get_post_meta( $post->ID, 'image_value', true ); ?>&w=225&h=246&zc=1" alt="<?php the_title(); ?>" /></a>";
As you can see its obviously because of the " and '.
The tags attributes (by attributes I mean 'alt' 'src' etc..) require a " while the php tags only work with ' .. so I didn't really know what to do hehe..
Any suggestions?
By the way, the CMS is wordpres. If it helps..
The issue is Wordpress functions like the_permalink and bloginfo use the echo function as well, so it doesn't work when you try to put the two together. They don't return anything. Instead, you want to use the functions that will return a string, so you can concatenate the return values with the HTML you want to output.
Try this:
echo "<a href='" . get_permalink() . "' rel='bookmark'><img src='" . get_bloginfo('template_directory') . "'/timthumb.php?src=";
You can fill in the rest.
Note: be wary of the rest of the answers. They appear to be answering the root of your question, but they ignore the nuances of the wordpress functions.
Check out PHP's strings and how to concatenate them
echo '<a href="'.the_permalink().'" rel="bookmark" ><img src="'.bloginfo( 'template_directory' ).'/timthumb.php?src='.get_post_meta( $post->ID, 'image_value', true ) .'&w=225&h=246&zc=1" alt="'.the_title().'" /></a>';
The title is showing only the first word when you mouse over the link. How can I get the whole order description to show? Thanks
<a title=$row[order_description] href=order.php?order_id=$row[qid]><font class=fontblueData_sub> $row[prod_title]</font></a>
Put the attribute in quotes, like it's supposed to be.
<a title="..." ...
You need double quote.
title="$row[order_description"
<?php
echo("<a title=\"" . $row[order_description] . "\" href=\"order.php?order_id=\"" . $row[qid] . "\">" . $row[prod_title] . "</a>")
?>
As suggested above, the code should look like:
<a title="<?= $row[order_description]; ?>" href="order.php?order_id=<?= $row[qid]; ?>">
<font class="fontblueData_sub"><?= $row[prod_title]; ?></font>
</a>