Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying data from a field by reference another field in the same ro

Status
Not open for further replies.

RottNKorpse

Technical User
Aug 8, 2006
13
Here's what I am trying to do...I am trying to make a hyperlink and an image source reference my sql database.

Lets say the table I am using has 3 fields in it which would be "Name", "MyURL" and "MyImage" hopefully the names of the fields dont matter because I will prolly change them later but for now thats what they are.

Now I want my page to display the following code:
<a href="<?=$pageheaderurl?>"><img src="<?=$pageheaderimage?>" border="0"></a>

I will have MANY rows in this table for different images and urls but I need to be able to reference one single row and have the link url and image url for a specific name on the page I am working on. It doesnt have to be dynamic in the sense of automaking the pages for this.

For Example:
Name=John
MyURL=http://fakeurl.com/image.jpg
MyImage=
I want <a href="<?=$pageheaderurl?>"> to only reference the data in the MyURL field for the name John and to not look at the other rows at all. Also the same thing for <img src="<?=$pageheaderimage?>" border="0"> with only referencing "John".

The sqlquery I tried didnt work as I was basically taking a guess on how it might work but since it didnt I gotta request some help. :)

Here is the query I used:
$pageheaderimagequery="SELECT name, myimage FROM pageheaders WHERE name = John";
$pageheaderimageresult=mysql_query($pageheaderimagequery);
$pageheaderimage=mysql_result($pageheaderimageresult,$i,"image_url");
$pageheaderurlquery="SELECT name, myurl FROM pageheaders WHERE name = John";
$pageheaderurlresult=mysql_query($pageheaderurlquery);
$pageheaderurl=mysql_result($pageheaderurlresult,$i,"link_url");

so could anyone help me out on this? I would really appreciate any help I can get.

Thanks,
RottNKorpse
 
just my luck...thats actually the usual problem I have...I forget simple crap and get it wrong. Like leaving off the ''s and forgetting to put the \\'s in html tags when doing php...I do that alot...its hard to remember such a stupid thing :) Anyway, thanks for the help...I'll try it out.

 
that worked...man I'm such a dolt for not seeing that. :) anyway thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top