Web link in a table

Most of my code writing skill comes from folowing examples or tutorials. I am trying to learn more as I go but like most people with little knowledge, simple things take hours of work to get right :slight_smile:

I am working on a project to present an events list in a table. I have the proper code to pull the items out of the database for each line. The last item is a URL. I can get the URL into my table but what I really want is the word “Results” which links to the URL in a new page when clicked.
Here is the section of code in question

[code]usort ( $contest, ‘order’ );

$savtitle = null;
$savdis = $contest[0][‘district’];
$j = $j+1;
for($i = 0; $i < $j; $i++)
{
if ($savtitle == $contest[$i][‘name’]) continue;
if ($savdis != $contest[$i][‘district’]) echo "

".$nbsp."

".$nbsp."

".$nbsp."

".$nbsp."

".$nbsp."

"; echo ""; echo "

".$contest[$i]['date']."

"; echo "

".$contest[$i]['state']."

"; #echo "

".$contest[$i]['district']."

"; echo "

".$contest[$i]['city']."

"; echo "

".$contest[$i]['name']."

"; echo "

".$contest[$i]['url']."

";

echo “

”; ;
$savtitle = $contest[$i][‘name’];
$savdis = $contest[$i][‘district’];
}

?>

[/code]

This is the line that I want to modify
echo “

”.$contest[$i][‘url’]."

";

the url is the address that I am pulling forom the DB that I want to link to.

For an example of what the page currently looks like.

http://nsrca.us/contest-results/2009/d1.html

Thank you for your time,
Stuart

below code should open a new tab with the url

[php]
$url = $contest[$i][‘url’];
echo “

$url”;
[/php]

Wow almost instant results thank you very much. I was on the right track but would have needed to see an exact reference to get the “punctuation” correct. I did have an issue with the clickable link being the same color as the background but easily resollved that. I replaced >$url< with >Results< so that my clickable link now says Results and takes you to the URL.

My only issue and I am not sure if this would be as easy to fix, is that not all of the entries have a URL to go to. Yet they all list the word Results. Those with a URL entered go where I want them and those without go to a blank page. Is there a way to have the file diferentiate? Either a different color if no link, unclickable or no word Results at all if the link is not there? If not a simple answer can you point me in the right direction to how this could be done, or an example, and I can work on it from there.

Thanks again,
Stuart

[php]
$url = $contest[$i][‘url’];

echo “

”;

//if nothing is in the url column of the database then “No Website Listed” is displayed
if($url == “”) {
echo “No Website Listed”;
} else {
echo “Results
}

echo “

”;
[/php]

missed an ;
[php]
$url = $contest[$i][‘url’];

echo “

”;

//if nothing is in the url column of the database then “No Website Listed” is displayed
if($url == “”) {
echo “No Website Listed”;
} else {
echo “Results”;
}

echo “

”;
[/php]

I need to keep you on speed dial :slight_smile:

I was thinking that an if/else statement would be the answer.

Now if I can ask a simple question to learn something why the double = in $url == “” What does that symbolize instead of a single =

Thanks again and again

in php = is used for assigning values, where as == means “is equal to”. basically php doesn’t use an extended character set, so there are only a limited number of symbols it can use. Triple, ===, can also be used and means “is equal to AND the same type” (e.g. an integer).

Thank you I had always been reading = as equal to but I understand now.

Sponsor our Newsletter | Privacy Policy | Terms of Service