title: How can I convert a text URL into a clickable link in a PHP page?
body: <p>I'm sure this is a really simple, obvious answer, but my brain is fried and I just can't seem to get it. I have a PHP site that allows users to post information to a text field in mySQL. The posts can all be viewed online. The field is a textarea in the HTML form when in post/edit mode, and static text in read mode. The users want to be able to include a URL in their posts and have it display as a clickable link, without having to include HTML in the field (which I don't want them to be able to do anyway - too risky.) So this is something that needs to be done when the data is displayed, rather than inserting html into the text when it's saved to the database.</p>
  
  <p>The code for the display is pretty simple:</p>
  
  <pre><code>$query = "SELECT * FROM meetings where id=".$_GET['id'];
  $result = mysqli_query($dbc, $query) or die('Error querying database');
  $rows = mysqli_fetch_array($result);
  
  echo "&lt;p&gt;&lt;div id=\"articleBody\"&gt;". $rows['body']. "&lt;/div&gt;&lt;/p&gt;";
  </code></pre>
  
  <p>Is there a function I can put around $rows['body'] that would display anything starting with http as a clickable link? Keeping in mind that the variable may or may not actually contain a URL.</p>