I am sure that this is a very simple, obvious answer, but my brain is fried, and I just can not understand it. I have a PHP site that allows users to post information to a text box in mySQL. Messages can be viewed online. A field is a text field in HTML form when it is in post / edit mode and static text in read mode. Users want to have a URL in their posts and display it as a click link, without having to include the HTML in the field (which I don't want them to be able to do anyway is too risky). this is what you need to do when the data is displayed, instead of inserting html into the text when it is saved in the database.
The code to display is pretty simple:
$query = "SELECT * FROM meetings where id=".$_GET['id'];
$result = mysqli_query($dbc, $query) or die('Error querying database');
$rows = mysqli_fetch_array($result);
echo "<p><div id=\"articleBody\">". $rows['body']. "</div></p>";
Is there a function that I can place around $ rows ['body'] that will display anything starting with http as a clickable link? Bearing in mind that a variable may or may not contain a URL.
source
share