Re: Text into a url
| From: | John W. Holmes | Date: | Sat, 13 Sep 2003 22:24:59 +0000 |
| Subject: | Re: Text into a url | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-162528@lists.php.net to get a copy of this message | ||
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 helpYou 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: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com