Jump to content


Photo

Add Hyperlinks to table cell info


  • Please log in to reply
5 replies to this topic

#1 rscott7706

rscott7706
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts
  • LocationLakeside CA

Posted 27 April 2006 - 03:19 AM

Hey all. I am creating a query table that will sample my MYSQL database with various fields.

I found this code, and it works great except I need to assign hyperlinks to fields ($row) 12 and 13.

I know it is a simple thing (I think), just adding the opening <A HREF and closing <a> to the code lines of 12 and 13, but I am at a loss as the the right syntax. Can you help?

echo "<table cellpadding=10 border=0>";
while($row = mysql_fetch_row($result)) {
echo "<tr>";
echo "<td>".$row[1]."</td>";
echo "<tr>";
echo "<td>" . $row[12]."</td>";
echo "<tr>";
echo "<td>".$row[13]."</td>";
echo "</tr>";
}
echo "</table>";

Thanks in advance!!

#2 sanfly

sanfly
  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationNew Zealand

Posted 27 April 2006 - 04:16 AM

So $row[12] and $row[13] are the URLs for the link?

If you're not part of the solution, you're part of the precipitate

#3 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 27 April 2006 - 04:51 AM

umm.. assuming that the value of $row[x] is the url, shouldn't this work?


echo "<table cellpadding=10 border=0>";
while($row = mysql_fetch_row($result)) {
echo "<tr>";
echo "<td>".$row[1]."</td>";
echo "<tr>";
echo "<td>[!--coloro:blue--][span style=\"color:blue\"][!--/coloro--]<a href='$row[12]'>[!--colorc--][/span][!--/colorc--]" . $row[12]."[!--coloro:blue--][span style=\"color:blue\"][!--/coloro--]</a>[!--colorc--][/span][!--/colorc--]</td>";
echo "<tr>";
echo "<td>[!--coloro:blue--][span style=\"color:blue\"][!--/coloro--]<a href='$row[13]'>[!--colorc--][/span][!--/colorc--]".$row[13]."[!--coloro:blue--][span style=\"color:blue\"][!--/coloro--]</a>[!--colorc--][/span][!--/colorc--]</td>";
echo "</tr>";
}
echo "</table>";
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#4 sanfly

sanfly
  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationNew Zealand

Posted 27 April 2006 - 05:00 AM

more like this

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]


echo "<table cellpadding=10 border=0>";
while($row = mysql_fetch_row($result)) {
echo "<tr>";
echo "<td>".$row[1]."</td>";
echo "<tr>";
echo "<td>[!--coloro:blue--][span style=\"color:blue\"][!--/coloro--]<a href='" . $row[12] . "'>[!--colorc--][/span][!--/colorc--]" . $row[12]."[!--coloro:blue--][span style=\"color:blue\"][!--/coloro--]</a>[!--colorc--][/span][!--/colorc--]</td>";
echo "<tr>";
echo "<td>[!--coloro:blue--][span style=\"color:blue\"][!--/coloro--]<a href='" . $row[13] . "'>[!--colorc--][/span][!--/colorc--]".$row[13]."[!--coloro:blue--][span style=\"color:blue\"][!--/coloro--]</a>[!--colorc--][/span][!--/colorc--]</td>";
echo "</tr>";
}
echo "</table>";
[/quote]
If you're not part of the solution, you're part of the precipitate

#5 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 27 April 2006 - 05:06 AM

well that's just coding preference. either way works (assuming that that's what he wants to do).
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#6 rscott7706

rscott7706
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts
  • LocationLakeside CA

Posted 27 April 2006 - 01:28 PM

Yes, the line numbers were the hyperlinks.

Works great!! Thanks all, I appreciate your responses!!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users