convert the url & hashtag into link
Posted: 07 Jan 2019, 08:39
I'm sorry to interrupt, I've been trying to ask a question on stackoverflow for an hour but I can not figure it out because they've changed their comment system
I have a function to convert the url & hashtag into link
this is working fine.... But my problem is I have
in my database also URL-links + Iframes but those
are not completely visible how it should be
I tried things with call-back function
but I can not figure it out ????
So I can`t make my URL-links + Iframes visible
I hope you have some ideas ????
I have a function to convert the url & hashtag into link
this is working fine.... But my problem is I have
in my database also URL-links + Iframes but those
are not completely visible how it should be
I tried things with call-back function
but I can not figure it out ????
So I can`t make my URL-links + Iframes visible
I hope you have some ideas ????
Code: Select all
<?php
//function to convert the url & hashtag into link
function convert_to_links($msg){
$final_message = preg_replace(array('/()#()/i'), array('<a href="$1" target="_blank">$1</a>', '$1<a href="">@$2</a>', '$1<a href="Read-Item.php?hashtag=$2">#$2</a>'), $msg);
return $final_message;
}
//if hashtag is requested
if(isset($_GET['hashtag']) && !empty($_GET['hashtag'])){
$hashtag = mysql_real_escape_string(strip_tags(trim($_GET['hashtag'])));
$query = mysql_query("SELECT * FROM politicsnucleus_item WHERE imore LIKE '%$hashtag%' ORDER BY inumber DESC");
$title = "Search Result For <span style='color:red;'>".$hashtag."</span> <a href='hashtag.php'>clear</a>";
}else{ // if not
$query = mysql_query("SELECT * FROM politicsnucleus_item ORDER BY inumber DESC LIMIT 15");
$title = "All Updates";
}
?>
<?php
echo $title;
//display the messages
if(mysql_num_rows($query) > 0){
while ($row = mysql_fetch_assoc($query)) {
$final_msg = convert_to_links($row['imore']);
echo '
<ul>
<li> '.$final_msg.'</li>
';
}
}
?>
<!--post will go here-->
</div>