Lee1007 Posted March 27, 2011 Share Posted March 27, 2011 I have created a database that echos out the result on a webpage, what i want to do is create one of the echo results into a link - the code is as follows: "Web Address: $web_address <br>" . Is there an easy way to make the result a link as the input will always be a web address? Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/231833-how-to-make-an-echo-a-link/ Share on other sites More sharing options...
floridaflatlander Posted March 27, 2011 Share Posted March 27, 2011 if it's 'something like this and its in repeating rows I use while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)){ echo '<a href="'. $row['id_member'] .'">' . $row['name'].'</a>'; } if its not repeating rows I use while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)){ $web_url = ''.$row['web_url'].''; $web_name = ''.$row['web_name'].''; } echo '<p><a href="http://'.$web_url.'">'.$web_title.'</a></p>'; Link to comment https://forums.phpfreaks.com/topic/231833-how-to-make-an-echo-a-link/#findComment-1192800 Share on other sites More sharing options...
floridaflatlander Posted March 27, 2011 Share Posted March 27, 2011 if its not repeating rows I use while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)){ $web_url = ''.$row['web_url'].''; $web_name = ''.$row['web_name'].''; } echo '<p><a href="http://'.$web_url.'">'.$web_title.'</a></p>'; Also on the last one I limit the results with $q = "SELECT * FROM table WHERE column = column-varaible LIMIT 1"; Link to comment https://forums.phpfreaks.com/topic/231833-how-to-make-an-echo-a-link/#findComment-1192802 Share on other sites More sharing options...
floridaflatlander Posted March 27, 2011 Share Posted March 27, 2011 Also on non-repeating rows $q = "SELECT column FROM table WHERE column = column-varaible"; $r = @mysqli_query ($dbc, $q); if (mysqli_num_rows($r) == 1) { // Has a valid column-varaible. // Get the source information: $row = mysqli_fetch_array ($r, MYSQLI_NUM); echo '<p><a href="http://'.$web_url.'">'.$web_title.'</a></p>'; Both work but I guess I have just used the first one I mentioned over time Link to comment https://forums.phpfreaks.com/topic/231833-how-to-make-an-echo-a-link/#findComment-1192810 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.