anchor title attribute - php

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>

Related

PHP: Echo IMG src= php echo

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 . "' >";

Outputting dynamic PHP code to insert into a dynamically created PHP page

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...

Link PHP inside an echo tag

I am having a problem with this code
<?php
echo '<div class="post_note2">
<b>'.$lang['RENEW_SUCCESS'].'</b></div><br /><span class="orange"><b>HOME|VIEW AD</b></span>';
}
}?>
for some reason when the VIEW AD link is clicked it doesn't build it properly and still contains the php code in the link rather than the link to the actual ad page. is it an issue with an echo in an echo ?
I'm sure this isn't quite difficult to solve but I have been trying for far to long on my own and cant get it.
Thanks, any help would be great.
You actually had it right in the first part of your string. You can't have and echo statement inside of another echo statement. Use concatenation throughout your string:
<a href="' . $adurl . '"
You have two extra brackets at the end and php text inside your echo.
<?php
echo '
<div class="post_note2">
<b>'.$lang['RENEW_SUCCESS'].'</b>
</div>
<br />
<span class="orange">
<b>
HOME | VIEW AD
</b>
</span>';
?>
All fixed given that $adurl is defined.
This
<?php echo $adurl; ?>
Should be
' . $adurl . '
i.e.
echo '<div class="post_note2"><b>'.$lang['RENEW_SUCCESS'].'</b></div><br /><span class="orange"><b>HOME|<a href="'.$adurl.'>VIEW AD</a></b></span>';

PHP+HTML Syntax

I am trying to get a webpage to display four divs that will hold an img and a description. I would like to use a loop because I will have other pages with many of these divs. Here is the code I am using now:
for ($i=0;$i<4;$i++)
{
echo '<div class="item">
<img src="IMGs\\' . $items[$i]["ImgFilename"] . '" />
<h6 class="panel">Description</h6>
</div>';
}
I believe the problem is that I am not escaping the correct way. I have been searching for a while but cannot find the right combination. Files are stored in IMGs\file.jpg where file.jpg is pulled from the array.
Your escaping seems fine to me. However, I think the problem is with the double backslash. Eg, remove the \\ and replace it with / So that line becomes:
<img src="IMGs/' . $items[$i]["ImgFilename"] . '" />
U dont need to escape this.
change this:
<img src="IMGs\\' . $items[$i]["ImgFilename"] . '" />
to <img src="IMGs/' . $items[$i]["ImgFilename"] . '" />
You can lay that code out a little better by breaking in/out of PHP as required, here's a quick example:-
<?php for($index = 0; $index < 4; $index++): ?>
<div class="item">
<img src="IMGs/<?php echo $items[$index]["ImgFilename"]; ?>" />
<h6 class="panel">Description</h6>
</div>
<?php endfor; ?>

iFrame only works for first array?

I'm using FancyBox to contain my iframes, but it only works for the first array. Here's what the array looks like:
$gallery_items = array(
array("img_src" => "gallery/thumb_1.jpg", "link" => "gallery/profile1.txt"),
array("img_src" => "gallery/thumb_2.jpg", "link" => "gallery/profile2.txt"),
and so on, and then here is how it is produced:
echo '<li><a id="various3" href ="' . $current_gallery_item["link"] . '"><img src="' . $current_gallery_item["img_src"] . '" /></a></li>';
the id="various3" is how FancyBox tells its an iframe. But, it only works for the first array.
Revised answer:
It seems you don't want iFrames but just load the content via Ajax. Your problem is that every element has the same ID. If you attach Fancybox via
$('#various3').fancybox();
then it will only be applied to the first element, because IDs have to be unique.
Use classes instead:
<ul>
<?php foreach($gallery_items as $item): ?>
<li>
<a class="various3" href ="<?php echo $item['link']; ?>">
<img src="<?php echo $item["img_src"]; ?>" />
</a>
</li>
<?php endforeach;?>
</ul>
And jQuery:
$('a.various3').fancybox();
If you really want to have iFrames, you can just add the iframe class to the link elements:
<a class="various3 iframe" ...>
This will automatically tell Fancybox to use iFrames.
See also Fancybox - How to use.
foreach($gallery_items as $current_gallery_item){
echo '<li><a id="various3" href ="' . $current_gallery_item["link"] .
'"><img src="' . $current_gallery_item["img_src"] . '" /></a></li>';
}
Might work
You used the same id (namely, "various3") for several elements.
This will not work this way.
Every id should be unique.
assign some class to A-tags and use it:
$("#various3")
--->
$(".various3")

Categories