Monday, 29 August 2016

Make PHP Hashtag system by using Regular Expression

In this exercise I have demonstrate the PHP hashtag conversion system. That system will convert any hast string to clickable link that directly link to hashtag rendering page. I have use regular expression from scrap to build this type of how to convert hash string to click able link. I have received many request from my viewer to make video tutorial on this type of topic. If you have use twitter or Facebook or google plus, on this of social networking site, you have show the link with hash tag, when you have click on that link so at that time you have show the result on string with hash tag on which you have click. If you want to build this type of system you have to watch this video tutorial on convert hash tag string to click able link. This type of feature mostly used in social network site in which you have see that when you have show to link with pound sign and when you click on that type of link you can find more information or result on which you have clicked word. This way you can get more result on your favorite keyword. This type of link mostly put on keyword, so you can find more result on that keyword, this way we can build a social network.

Source Code


 //Title - Make PHP Hashtag system by using Regular Expression  
 function convertHashtoLink($string)  
      $expression = "/#+([a-zA-Z0-9_]+)/";  
      $string = preg_replace($expression, '<a href="hashtag.php?tag=$1">$0</a>', $string);  
      return $string;  
 $string = "#PHP means Hypertext Preprocessor<br />";  
 $string .= '#mysql is a nice database<br />';  
 $string .= "#Jquery is a Javascript Library<br />";  
 //<a href="">PHP</a>  
 $string = convertHashtoLink($string);  
 echo $string;  


      $tag = preg_replace("#[^a-zA-Z0-9_]#", '', $_GET["tag"]);  
      echo '<h1>' . $tag . '</h1>';  
      $connect = mysqli_connect("localhost", "root", "", "testing");  
      $query = "SELECT * FROM tbl_blog where blog_title LIKE '%".$tag."%'";  
      $result = mysqli_query($connect, $query);  
      if(mysqli_num_rows($result) > 0)  
           while($row = mysqli_fetch_array($result))  
                echo '<p>'.$row["blog_title"].'</p>';  
           echo '<p>No Data Found</p>';  

1 comment:

  1. sir please post a tutorial for storing frontend editable html table to backend using php & mysql