473,320 Members | 1,839 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Using a variable in a hyperlink

I'm trying to wite a code that can take a web address from a variable and out it into a hyperlink.

This is what I have so far:

Expand|Select|Wrap|Line Numbers
  1. // display the results returned
  2.  
  3.   while ($row= mysql_fetch_array($result)) {
  4.   $title = $row["song_name"];
  5.   $artist = $row["artist"];
  6.   $genre = $row["genre"];
  7.   $SongID = $row["SongID"];
  8.   $Buy = $row["purchase_link"];
  9.  
  10.   echo "$count.) $title" ;
  11.   echo " - " ;
  12.   echo  "$artist"  ;
  13.   print( '<a href="$Buy">Buy this track</a>' );
  14.   $count++ ;
  15.   }
  16.  
This doesn't work (stating the obvious or I woudn't be asking!), so any ideas, tips etc.?
Apr 6 '11 #1
2 1676
Dormilich
8,658 Expert Mod 8TB
use either " instead of ' or take the variables out of the string or use printf().
Expand|Select|Wrap|Line Numbers
  1. printf('<a href="%s">Buy this track</a>', $Buy);
Apr 7 '11 #2
Works perfectly! thanks a lot for your help
Apr 8 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: J P Singh | last post by:
Hi Guys How can i use the variable name instead of a hardcoded value when writing a hyperlink. strBody = strBody & "<a href="default.htnk">Login</a>" I would like to use a variable name...
0
by: KathyB | last post by:
Hi, I'm using the following xmlDocument and xpath to load a file using a variable. I've tried several renditions of the xpath using the variable but without success (error: object variable not...
1
by: VJ | last post by:
I want to pass two variable with the <asp:HyperLink> tag but I'm a little unsure... i tried... <asp:HyperLink ID="hyperlink1" NavigateUrl="tickets.aspx?time=<%#...
1
by: kelvinweb | last post by:
Hi All, Is it possible to using variable store container.dataitem in ItemTemplate ?? For example. <ItemTemplate> <% Dim x x = container.dataitem("LineNo")
9
by: dana lees | last post by:
Hello, I am using asp:HyperLink in a c# asp.net application to open a new window in the following way: <asp:HyperLink ID="lnkSiteName" runat="server" Text='<%# DataBinder.Eval(Container,...
2
by: 张韡武 | last post by:
We have preffered language set as variable in xslt: <xsl:variable name="preferred_language"> zh </xsl:variable> Data: <name xml:lang="de">Raw Materials (Mining incl.)</name> <name...
9
by: Chad | last post by:
This might be a bit vague and poorly worded..... In my program, I handle function failures using fprintf() and exit() like: fprintf(stderr, "malloc failed"); exit(EXIT_FAILURE); There...
2
by: bhargavigupta | last post by:
hi i am having hylink column like id in gridview so i put navigate Url to another page so when i click one hyperlink it has to transfer to next page and it has to print the total...
1
by: ragonz | last post by:
Hi, i'm kind of newbie in java programming. Now, i'm working on my task, n i hav a problem in using variable from other method. Here goes the code.. import java.awt.*; import java.awt.event.*;...
1
by: smartic | last post by:
how can i assign value to static var inside class using variable variables technique ex: self::$$var = $value;
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.