Onmouseover - incorrect layout? - php

I have the following code in my php file:
print "<a onmouseover=document.getElementById('merchantlogo').src='/store/logos/".$infobrand['merchant']."' href='/merchant/".$infobrand['merchant']."'>".$infobrand['merchant']." (".$infobrand['Total'].")</a>"
What I'm trying to do is have image box "merchantlogo" change to $infobrand['merchant'] on hover.
The problem is that the names of the merchants have spaced in their names, that I can't easily change.
It appears that these spaces are causing problems and are been treated separately.
Here's how it appears on page source:
<a onmouseover=document.getElementById('merchantlogo').src='/store/logos/Next Day DIY' href='/merchant/Next Day DIY'>Next Day DIY (667)</a>
I think there needs to be quote marks after the onmouseover? I'm new to PHP and am unsure how to add these in?
Any info would be really helpful!
Cheers
Chris

Change this
print "<a onmouseover=document.getElementById('merchantlogo').src='/store/logos/".$infobrand['merchant']."' href='/merchant/".$infobrand['merchant']."'>".$infobrand['merchant']." (".$infobrand['Total'].")</a>"
to
print "<a onmouseover=\"document.getElementById('merchantlogo').src='/store/logos/".$infobrand['merchant']."'\" href='/merchant/".$infobrand['merchant']."'>".$infobrand['merchant']." (".$infobrand['Total'].")</a>"

Related

change font colour within php echo

I have a html hyperlink within a php echo, this in itself has taken me a while to get working correctly, the code is below:
echo "Guidance on Organisational Context can be found".' here';
What I would like to do is change the text colour of the entire text, the examples i have found so far on google only change text of the hyperlink "here", otherwise i just dont know how to insert the additional html into the existing code, any suggetions would be greatly appreciated.
Also i would prefer #111111 style colour picker if possible
its ok i resolved this by adding two lines:
echo '<span style="color:#f44242;text-align:left;">Guidance on Organisational Context can be found</span>';
echo " ".' here'."<BR>";

Add a hyperlink to each entry of a table from mysqli

I'm trying to add a direct link to the genomic region of each gene on a table generated with mysqli data, but can't figure out the way. The idea is that every gene name has a hyperlink to it's region on a genome browser.
The problem comes when I have to generate the link dynamically for each gene depending on the gene selected by the user.
I've tried this:
echo '<td><a href="http://genome.ucsc.edu/cgi-bin/hgTracks?"'.urlencode($genome.$row['name2'])'>'$row['name2']'</a></td>';
$genome is the par of the url specific for each species and assembly, and $row['name2'] is the name of each gene.
I complete my previous comment with some advice - maybe this is the answer to your question.
1. How to use echo
You should separate each part of the echo function by a separator.
The common separator is the coma ,. Of course, you can also concatenate with a dot .
echo 'a', 'b', 'c', $var, 'con'ca' . 'tenated';
Tips: use the coma only for echo instruction. It's faster :)
2. Issues on your code
If I take your generated output, you should have something like this - with **cho* corrections:
<td><a href="http://genome.ucsc.edu/cgi-bin/hgTracks?"%20gen%20The+name>The name</a><td>
As you can see, the link is http://genome.ucsc.edu/cgi-bin/hgTracks?. The content after the " is ignored.
Solution: Move to the dynamic part of the link, at the correct place :)
You had your quote double quote in wrong location if there are additional problems will need more info
// Yours
echo '<td><a href="http://genome.ucsc.edu/cgi-bin/hgTracks?"'.urlencode($genome.$row['name2'])'>'$row['name2']'</a></td>'
// Fixed Quote
echo '<td>'$row['name2']'</td>';

How can I fix this HREF issue

I am struggling with an issue which I need a little bit of help with, basically I have created a search bar and when the results come up I only want the 'Session 1' or 'Session 2' to be href'd. Not the whole thing. A photo below:
img http://gyazo.com/eb677171c15b075f1fb4137d28227b3a.png
I would just like the Sessions to be hrefed but the paragraphs just.
My code below:
echo "<p><a href='../pages/session.php</a>".$results['1']."'><h3>".$results['title']."</h3>".$results['text']."</‌​p>";
Linking to my DB
Note that is not all of my code just where I believe the issue lies.
You placed </a> slightly wrong. The correct solution would be like this:
echo "<p><a href='../pages/session.php'>{$results['1']}</a><h3>{$results['title']}</h3>{$results['text']}</‌​p>";
If you use double quotes, you do not need to concatenate variables into your string, they are also validate within the string.
UPDATE
To display only the headlines as links try this:
echo "<a href='../pages/session.php'><h3>{$results['title']}</h3></a><p>{$results['text']}</‌​p>";
You have missed a bracket in ur a tag.It is like <a href='whatever'>blah</a>
Do you just want to href $results['1']? Here you go.
echo "<p><a href='../pages/session.php'>".$results['1']."</a><h3>".$results['title']."</h3>".$results['text']."</‌​p>";

Uploadify cancel individual file problem

I have implemented uploadify in to my web application and it all works brilliantly except one thing. When the files are displayed in the queue, when I go to remove one from the queue I get an error.
The error is:
illegal character
jQuery(\'#'+a(this).attr(
and the code which this refers to is this:
<a href="javascript:jQuery(\'#'+a(this).attr("id")+"').uploadifyCancel('"+i+'\')">
If you could advise me that would be great. Thanks.
This was the working code, he just modified it wrong.
<a href="javascript:$('#file_upload').uploadifyCancel($('.uploadifyQueueItem').eq(i).attr('id').replace('file_upload',''))">
The i variable defines which upload in the queue to cancel i.e. 0 is first, 1 second, -1 is last, -2 second last etc.. Alernatively if you have already grabbed the upload ID from uploadify, you can just do..
<a href="javascript:$('#file_upload').uploadifyCancel(ID)">
For reference in case anyone ends up here
http://www.uploadify.com/documentation/methods/uploadifycancel/
Also see http://api.jquery.com/eq/
I think you are getting the quotes mixed up and escaped wrong. Try this:
<a href="javascript:jQuery('#'+a(this).attr('id')).uploadifyCancel(i)">
Your quotation marks are wrong.
the value of the href attribute should be surrounded by " marks. The value itself should contain only ' marks. Escape them properly (\') when necessary.

How would I jump to a point in a page using the hash or pound symbol(#) with a get variable?

I found this tutorial that explains what I want to do using html but when I echo out the code with a get variable there is no affect to the page. I would use, for example, the following code:
echo "<a href='post.php?id=".$id."#Comments'>Click here to go to the comments</a>";
echo "<a title='Comments'>Comments</a>";
I presume the problem is to do with the get variable, so would I have to end it, some how, before using the # symbol?
The problem actually lies in your HTML, because the anchor should be parsed correctly by browsers regardless of the query string.
Page anchors use the name attribute instead of the title attribute:
<a name='Comments'>Comments</a>
You can also apply this to the id attribute of any element:
<h2 id='Comments'>Comments</h2>
To define jump-labels you have to set a name and/or id-attribute:
echo "<a title='Comments' name='Comments' id='Comments'>Comments</a>";

Categories