Jump to content

How to make an echo a link?


Lee1007

Recommended Posts

I have created a database that echos out the result on a webpage, what i want to do is create one of the echo results into a link - the code is as follows:

 

"Web Address: $web_address <br>" .

 

Is there an easy way to make the result a link as the input will always be a web address?

 

Thanks in advance! :)

Link to comment
https://forums.phpfreaks.com/topic/231833-how-to-make-an-echo-a-link/
Share on other sites

if it's 'something like this and its in repeating rows I use

 

while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)){

 

echo '<a href="'. $row['id_member'] .'">' . $row['name'].'</a>';

 

}

 

if its not repeating rows I use

 

while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)){

 

$web_url = ''.$row['web_url'].'';

$web_name = ''.$row['web_name'].'';

}

 

echo '<p><a href="http://'.$web_url.'">'.$web_title.'</a></p>';

if its not repeating rows I use

 

while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)){

 

$web_url = ''.$row['web_url'].'';

$web_name = ''.$row['web_name'].'';

}

 

echo '<p><a href="http://'.$web_url.'">'.$web_title.'</a></p>';

 

 

Also on the last one I limit the results with $q = "SELECT * FROM table WHERE column = column-varaible LIMIT 1";

Also on non-repeating rows

 

$q = "SELECT column FROM table WHERE column = column-varaible";

 

$r = @mysqli_query ($dbc, $q);

 

if (mysqli_num_rows($r) == 1) { // Has a valid column-varaible.

 

// Get the source information:

$row = mysqli_fetch_array ($r, MYSQLI_NUM);

 

echo '<p><a href="http://'.$web_url.'">'.$web_title.'</a></p>';

 

Both work but I guess I have just used the first one I mentioned over time

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.