Create A Dynamic ‘Read More’ Link Using PHP

Today, I am working to create dashboard like wordpress, means there are number of stories and each story has too much description. I have a problem – how to avoid lengthy description onto the dashboard page. I have seen many website if the description text is larger than few characters will show, the extra words are hide and a show more link is appeared to user.

So I need to create “Read More…” link and if the users is interested then he can click on more link and see the full content.

You can also check other tutorial of dynamic read more Using jQuery

Here is a simple tutorial to achieve “Read More..” link functionality.

To create link dynamically, I need first to create connection with database.

Created Database Connection With MySQLI

Created connect.php file into php application, We will pass MySQL server hostname, username, dbname and password into mysqli_connect() method.

Get All Records With MySqli

We will get all records with description data from database.

Now I am creating a readMoreFunction(...) general function to display link on dashboard.

Above functionally has been created using of core php ,you can also create this functionality with jquery and PHP

.

I hope this will help you!

Demo and Download Source Code