Solved

my Database 'url' achor sends links to index page

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP Syntax Error 4 32
Number of hours between date in DB and now 8 21
how to call a remote wordpress to use his  content in a loop 3 35
Undefined variable problem 5 23
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
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.

860 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