Solved

my Database 'url' achor sends links to index page

Posted on 2002-04-25
3
184 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

763 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