creatives Posted November 26, 2009 Share Posted November 26, 2009 Hi guys, I am slowly learning about php and mysql. I am inputting my database via phpmyadmin. However, I am struggling on something I just can't seem to find an answer on, and thats displaying url data on a webpage, using php, but as text links, for eg "Joe bloggs runs down the road" that is clickable and opens in a new window. Do I have to imput the URL in a separate field from the description within a database table, and display them as text links via customised php code, or is there a way of setting this up in phpmyadmin or mysql so that one field displays as a text link? Any suggestions? Your help would be really appreciates as I am totally stuck :-\ Many thanks! Quote Link to comment Share on other sites More sharing options...
fenway Posted November 26, 2009 Share Posted November 26, 2009 If you're talking about including HTML in a field, this has nothing to do with either php or mysql... just dump out the contents as-is (assuming you're not messing around with entities and such). Otherwise, if you want to link the entire record to something, you'll need another field. And no, phpmyadmin doesn't know anything about either of these. Quote Link to comment Share on other sites More sharing options...
creatives Posted November 26, 2009 Author Share Posted November 26, 2009 Thanks for the reply. Hmm ok, so how would you recommend I make a simple links site, with links shown as descriptions by using a mysql database. Sorry if I am posting in the wrong section, but I am really stuck as to what to do next. Basically, my site will be numerous webpages, each webpage will be for an individual person, and I would like to display links that relate to that person on their webpage, but shown as description. I know how to set up a mysql database via my hosting provider, and I know how to populate it via phpmyadmin. I could always set up a php script to populate the database instead if you feel this is a better method. Its just this displaying of links as decriptions that driving me crazy, lol :'( Thanks for your help! Quote Link to comment Share on other sites More sharing options...
merylvingien Posted November 26, 2009 Share Posted November 26, 2009 You could store the link in one table say A ( http://www.yoursite.com ) Put the link text in another table, say B ( some text for the link ) then in your page populate the links from your database. $sql = "SELECT * FROM database"; mysql_query($sql) $result = mysql_query($sql); $row = mysql_fetch_assoc($result); echo "<a href='{$row['A']}'>{$row['B']}</a>"; I havent tested this, but that should give you a link that reads some text for the link and links to www.yoursite.com Quote Link to comment Share on other sites More sharing options...
creatives Posted November 27, 2009 Author Share Posted November 27, 2009 Thanks for that! very helpful:) Can I not put the url link in a separate field within the same table as the description text? Just wondering why it has to be in a separate table? Thanks! Quote Link to comment Share on other sites More sharing options...
trq Posted November 27, 2009 Share Posted November 27, 2009 Thanks for that! very helpful:) Can I not put the url link in a separate field within the same table as the description text? Just wondering why it has to be in a separate table? Thanks! The above code does exactly that. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.