SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    May 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Insert link from mysql database into html

    In my mysql database, I have web addresses which I want to bring into an html page.

    <a href="url from mysql database">Link text</a>

    How do I do this?

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php

    mysql_connect
    ('hostname''username''password');
    mysql_select_db('databasename');

    $query "SELECT url FROM table";
    $result mysql_query($query);

    while (
    $row mysql_fetch_array($result)) {
     
      echo 
    '<a href="' $row['url'] . '">Link Text</a> ';

    }

    ?>

  3. #3
    SitePoint Member
    Join Date
    May 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •