Solved

my Database 'url' achor sends links to index page

Posted on 2002-04-25
3
178 Views
Last Modified: 2011-09-20
The code below is getting me info. from the database.  One of the results - website - is supposed to enable clients to then link the block to a website.  It gives me the link - but then this link goes to the index page within the same web and not where it says.  can someone help.  Thank you


<html>
<head>
<title>Displays</title>
</head>
<body>
<?php
     $db_name = "xxxxxxx";
  $table_name = "xxxxxxx";
  $connection = @mysql_connect("xxxxxxxx.com", "xxxxxx", "xxxxxx") or
                die("could not establish a connection");
          $db = mysql_select_db($db_name, $connection) or die("could not select the database");
$sql = "
select cust_num,website,industry,other,co_name,email,address,country,city,telephone,
biz_desc
from $table_name
order by cust_num desc
";
$result = @mysql_query($sql, $connection) or die("could not execute query");
while ($row = mysql_fetch_array($result))
{
           $website= $row['website'];
         $industry = $row['industry'];
            $other = $row['other'];
          $co_name = $row['co_name'];
            $email = $row['email'];
          $address = $row['address'];
          $country = $row['country'];
             $city = $row['city'];
        $telephone = $row['telephone'];
         $biz_desc = $row['biz_desc'];
   $display_block .= "
<p><strong><a href=\"$url\">$website</a></strong>.......($industry).......|.....($other).......
($co_name)...|...($email)....|...($address)....|....($country)....|...($city)...|...($telephone)..|
($biz_desc)
";
}
?>
<h2>New Displays</h2>
<?php echo "$display_block"; ?>
<p><a href="http://easternafricatimes.com/cod/afro.php">Return to Menu</a></p>
</body>
</html>


0
Comment
Question by:Senyonjo
3 Comments
 
LVL 5

Expert Comment

by:andriv
ID: 6970385
If the link is suppose to take you to another site you have to begin it with http://

$display_block .= "
<p><strong><a href=\"http://$url\">$website</a></strong>.......($industry).......|.....($other).......
($co_name)...|...($email)....|...($address)....|....($country)....|...($city)...|...($telephone)..|
($biz_desc)
";

The change is needed here:

<a href=\"http://$url\">
0
 
LVL 1

Accepted Solution

by:
nathan8 earned 100 total points
ID: 6981898
Senyonjo,

This may be a simple answer.  You don't seem to be creating a local value for $url.  In fact, the value of the variable $url would be "" in this script.  You probably need to pull it out of the result array in the same fashion you got the rest of your variables:

$url= $row['url'];

With this set, your code below:

<a href=\"$url\">

should work fine!

Also, Andriv is right, you must begin the link with http://

-Nate
0
 

Author Comment

by:Senyonjo
ID: 6982826
Nathan8's ans. was excellent.  It has worked for me.  Thanks Nathan8
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article discusses four methods for overlaying images in a container on a web page
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now