Solved

my Database 'url' achor sends links to index page

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
The viewer will learn how to dynamically set the form action using jQuery.
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 …

734 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