Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.