# Solved: a href within PHP loop



## vipernet (Aug 23, 2007)

hey all,

Trying to figure out how i can add a

```
<a href=
```
 into my php loop:

Here is the loop:

```
<?php
$row = 0;
while ($Resultset = $MyDb->f_GetRecord($Result)) {
$str = (($row++ % 2) == 0 ) ? '[TR]' : '[TR]';
echo $str;

echo '[TD]'.$Resultset['item'].'[/TD]';
echo '[TD]'.$Resultset['computer_name'].'[/TD]';
echo '[TD]'.$Resultset['room'].'[/TD]';
echo '[TD]'.$Resultset['brand'].'[/TD]';
echo '[TD]'.$Resultset['school'].'[/TD]';

}
?>
```
there is more to the script but the page i want to display as a link is:


```
echo '[TD]'.$Resultset['computer_name'].'[/TD]';
```
Just can't figure out where to put the <a href= without getting some kind of syntax error.

any suggestions/help would be great

Thanks


----------



## cpscdave (Feb 25, 2004)

you should be able to do:


```
echo '[TD][URL]SOME LINK NAME[/URL][/TD]';
```
or

```
echo "[TD][URL]SOME LINK NAME[/URL][/TD]";
```


----------



## vipernet (Aug 23, 2007)

the link is actually the value from the sql database.
'computer_name' is the Field within SQL


----------



## cpscdave (Feb 25, 2004)

So is 
$Resultset['computer_name'] something like http://www.somesite.com
or SOME LINK NAME

if its the prior what I put before would work
other wise 
print "[TD]{$ResultSet['computer_name']}[/TD]";
would work.


----------



## MMJ (Oct 15, 2006)

```
echo '[TD][URL='. $linkHref.']'.$linkName.'[/URL][/TD]';
```
make sure you change the variable names.


----------



## vipernet (Aug 23, 2007)

figure it out using this Code:

```
echo '[TD][URL='. $Resultset['computer_name'].']'.$Resultset['computer_name'].'[/URL][/TD]';
```
thank you everyone for the help


----------



## MMJ (Oct 15, 2006)

anytime


----------

