How To: Read More Link

Last updated on July 27, 2021 by Mike Dalisay

Creating a Read More link saves space in your page especially if you want to display a list of articles. It is much better than displaying the whole content of an article.

How To: Read More Link
Read More Link

Step 1: Prepare your database configuration file.

Step 2: Create your index.php file. You should have these codes.

include 'config_open_db.php'; // For database connection

// SUBSTR function in the query is used to shorten the output of the content
$sql = "select id, title, SUBSTR( body, 1, 300 ) as body from articles";
$rs = mysql_query( $sql ) or die( 'Database Error: ' . mysql_error());
while( $row = mysql_fetch_array( $rs ) ){
    extract( $row ); // to have variable names the same with column names
    echo "<h4>$title</h4>";
    echo "$body";
    // Link to the page where the reader can read the whole article
    echo "...[<a href='read_news.php?page_id=$id'>Read More</a>]";

By Mike Dalisay

Hi, I'm Mike Dalisay, a coder and startup founder. Thank you for visiting! I'm also passionate about technology and enjoy sharing my experience and learnings online. Connect with me on Twitter, LinkedIn, Facebook, and Instagram.

Back to top