Jump to content

[SOLVED] create a link from information in a mysql database


drkshenronx

Recommended Posts

First and foremost I am a total newb to php and mysql, so please bear with me!!

Heres my problem, I want to add websites into a mysql database by their name and website url. I want the url to be a link when it is displayed on the page instead of just plain text. Heres the snippet of code that I am using to display information from the database query.

 

if(mysql_num_rows($result) == 0){

        echo("Nothing to Display!");

    }

 

    $bgcolor = "#E0E0E0";

 

    echo("<table>");

   

    while($row = mysql_fetch_array($result)){

        if ($bgcolor == "#E0E0E0"){

            $bgcolor = "#FFFFFF";

        }else{

            $bgcolor = "#E0E0E0";

        }

 

    echo("<tr bgcolor=".$bgcolor."><td>");

    echo($row["page_name"]);

    echo("</td><td>");

    echo($row["website_url"]);

    echo("</td></tr>");

    }

 

    echo("</table>");

 

 

Here is my output

 

 

Name of website 1

            somewebsite.com

Name of website 2

            somewebsite2.com

Name of website 3

            somewebsite3.com

 

 

 

The following line is the one I need help modifying

 

echo($row["website_url"]);

 

I want to change it so that the website url is displayed as a link instead of just plain text. Can anyone help me with this?

Link to comment
Share on other sites

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.