Professional Web Applications Themes

Text into a url - PHP Development

Hi I am havening a problem retrieving url from a mysql database. I have the url's stored as text and am using the following code to retrieve them $query = "SELECT name,url FROM clubs WHERE url>'' ORDER BY name"; $result = mysql_query($query) or die ("Query failed"); if (mysql_num_rows($result) == 0) { print "No Club Links Found."; } else { while ($row = mysql_fetch_assoc($result)) { print $row["name"] . "<A HREF= ".$row['url'].">"; This seems to work except the url refers to the previous name on the list produced with the first name as a blank url. Can anybody help Thanks...

  1. #1

    Default Text into a url

    Hi
    I am havening a problem retrieving url from a mysql database. I have the
    url's stored as text and am using the following code to retrieve them


    $query = "SELECT name,url FROM clubs WHERE url>'' ORDER BY name";

    $result = mysql_query($query) or die ("Query failed");

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

    print "No Club Links Found.";

    } else {

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

    print $row["name"] . "<A HREF= ".$row['url'].">";


    This seems to work except the url refers to the previous name on the list
    produced with the first name as a blank url.
    Can anybody help

    Thanks
    Tom Wollaston Guest

  2. #2

    Default Re: [PHP] Text into a url

    Tom Wollaston wrote:
    > Hi
    > I am havening a problem retrieving url from a mysql database. I have the
    > url's stored as text and am using the following code to retrieve them
    >
    >
    > $query = "SELECT name,url FROM clubs WHERE url>'' ORDER BY name";
    >
    > $result = mysql_query($query) or die ("Query failed");
    >
    > if (mysql_num_rows($result) == 0) {
    >
    > print "No Club Links Found.";
    >
    > } else {
    >
    > while ($row = mysql_fetch_assoc($result)) {
    >
    > print $row["name"] . "<A HREF= ".$row['url'].">";
    >
    >
    > This seems to work except the url refers to the previous name on the list
    > produced with the first name as a blank url.
    > Can anybody help
    You have incorrect HTML. You're last line should look like this:

    print "<a href=\"{$row['url']}\">{$row['name']}</a>";

    You were starting your link after you printed out the value, without
    ending the link, so it continued to the next item and only ended when
    the next link started on the next row.

    --
    ---John Holmes...

    Amazon Wishlist: [url]www.amazon.com/o/registry/3BEXC84AB3A5E/[/url]

    php|architect: The Magazine for PHP Professionals [url]www.phparch.com[/url]
    John W. Holmes Guest

  3. #3

    Default Re: [PHP] Text into a url

    $query = "SELECT name,url FROM clubs WHERE url>'' ORDER BY name";
    ??

    could it not be

    $query = "SELECT name,url FROM clubs WHERE url !="" ORDER BY name";
    > Hi
    > I am havening a problem retrieving url from a mysql database. I have
    > the url's stored as text and am using the following code to retrieve
    > them
    >
    >
    > $query = "SELECT name,url FROM clubs WHERE url>'' ORDER BY name";
    >
    > $result = mysql_query($query) or die ("Query failed");
    >
    > if (mysql_num_rows($result) == 0) {
    >
    > print "No Club Links Found.";
    >
    > } else {
    >
    > while ($row = mysql_fetch_assoc($result)) {
    >
    > print $row["name"] . "<A HREF= ".$row['url'].">";
    >
    >
    > This seems to work except the url refers to the previous name on the
    > list produced with the first name as a blank url.
    > Can anybody help
    >
    > Thanks
    >
    > --
    > PHP General Mailing List ([url]http://www.php.net/[/url])
    > To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]
    daniel@electroteque.org Guest

Similar Threads

  1. Replies: 6
    Last Post: September 9th, 10:03 AM
  2. #38805 [NEW]: PDO Truncates Text from SQL Server Text Data Type Field
    By gkrajci at arescorporation dot com in forum PHP Bugs
    Replies: 13
    Last Post: October 14th, 10:31 PM
  3. Coursebuilder - 5 text areas for 5 possible scores. Eachpossible answer has its own text area
    By seaweed2323 in forum Macromedia Exchange Dreamweaver Extensions
    Replies: 0
    Last Post: June 27th, 04:20 AM
  4. current selected text to highlighted text on mouse up event through java script
    By mandal.tanmay@gmail.com in forum Adobe Acrobat SDK
    Replies: 0
    Last Post: February 8th, 12:09 PM
  5. text field including text from a text file *.txt
    By Bernd Bach in forum Macromedia Flash
    Replies: 0
    Last Post: April 13th, 09:37 AM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139