I have a database that contains a field that are links,I can display the url on the page but can anyone tell me how to make the link go to the url it points to when clicked? or even better a button that is clickable. This is my code: $data = mysql_query("SELECT * FROM mydatabase WHERE class LIKE'weather'"); while($result = mysql_fetch_array( $data )) { echo $result['weather_today']; echo "<br>"; echo $result['weather_next']; echo "<br>"; echo $result['url']; echo "<br>"; echo "<br>"; } ?> Code (markup): Thank you...
Is this what you're looking for? $data = mysql_query("SELECT * FROM mydatabase WHERE class LIKE'weather'"); while ($result = mysql_fetch_array($data)) { echo($result['weather_today']); echo("<br>"); echo($result['weather_next']); echo("<br>"); // the link? echo("<a href='".$result['url']."' target='_blank'>".$result['url']."</a>"); echo("<br>"); echo("<br>"); } ?> Code (markup):
Thank you Altari thats great ! This is the rubbish I had tried to write: echo "<a href=\"".$result."\" target=\"_blank\">url</a>"; Do you know how to add a button for the link instead of text ?
Like a submit button? You could do echo("<a href='".$result['url']."' target='_blank'><input type='submit' value='Go To Teh Link' /></a>"); Code (markup): Or you could do as suggested by Natalic, to use any image echo("<a href='".$result['url']."' target='_blank'><img src='LINK TO IMAGE' alt='SOME ALT TEXT' /></a>"); Code (markup):