Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

PHP Mysql and Hyperlinks

Posted on 2002-03-27
1
Medium Priority
?
267 Views
Last Modified: 2012-05-04
This php block will enable me to retrieve data from a mysql database.  How can I create a link on results of the block?. My intention is to enable users to link right after a successful database search. ie link from co_name (result) to company website.
---------
$sql = "
select co_name, industry, other, your_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))
{
$co_name        = $row['co_name'];
$industry       = $row['industry'];
$other                 = $row['other'];
$your_name      = $row['your_name'];
$email          = $row['email'];
$address        = $row['addres'];
$country        = $row['country'];
$city           = $row['city'];
$telephone      = $row['telephone'];
$biz_desc       = $row['biz_desc'];
$display_block .= "
<strong>$co_name</strong><br>
($co_name) | ($industry) | ($other) | ($your_name) | ($email) | ($address)<br>
($country) | ($city) | ($telephone)<br>
<em>($biz_desc)</em>
";
}
?>
<? echo "$display_block"; ?>
</body>
</html>
0
Comment
Question by:Senyonjo
1 Comment
 
LVL 5

Accepted Solution

by:
andriv earned 200 total points
ID: 6900528
Add the anchor tag around $co_name but where are you getting the URL from. In the example below I used a variable for the URL but you are going to have to get the value from somewhere, most likely the db

$display_block .= "
<strong><a href=\"$url\">$co_name</a></strong><br>
($co_name) | ($industry) | ($other) | ($your_name) | ($email) | ($address)<br>
($country) | ($city) | ($telephone)<br>
<em>($biz_desc)
";
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
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…
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.
Suggested Courses

885 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