drkshenronx Posted December 11, 2007 Share Posted December 11, 2007 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? Quote Link to comment Share on other sites More sharing options...
timmah1 Posted December 11, 2007 Share Posted December 11, 2007 Try this echo "<a href=\"$row[website_url]\">$row[website_url]</a>"; Quote Link to comment Share on other sites More sharing options...
tapos Posted December 11, 2007 Share Posted December 11, 2007 Just use this echo('<a href="'.$row["website_url"].'">'.$row["website_url"].'</a>'); Thanks -- Tapos Pal Quote Link to comment Share on other sites More sharing options...
drkshenronx Posted December 11, 2007 Author Share Posted December 11, 2007 Thanks so much for the help Tapos !! Your script worked like a charm. And only a few minutes after posting it's working !!! 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.