Solved

my Database 'url' achor sends links to index page

Posted on 2002-04-25
3
179 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
simplest php form 3 61
PHP warning 4 30
How to loop bootstrap columns which contain database records 9 20
how to handle $x_amount to payment gateway in php - stumped. 14 13
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

910 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

25 Experts available now in Live!

Get 1:1 Help Now