I’m noob so can anyone teach me how to make “Read more” in my article?
thanks in advance m8
It requires a program like wordpress, once you have wordpress, create a new post, then go to the visual tab, and you will see a thing that has a split line down the middle on the bar above the text, near the right. Put that where you want it to say read more.
You can probably create a table containing fields, id, subject and content.
Then just display the subject lines on the page and a link “read more…” to pass id=$id.
When “read more…” is clicked, the passed id value is used in mysql query to match id in the table and display the content.
Yes, but he said he was a “noob” (his words) in his first sentence, so he is not going to understand that most likely…
Oh yeah, that is right. R u using CMS to manage your articles?
If u’re only using simple HTML
just display your subject lines… and hyper link to your content page.
for example
Subject1<a href=“content1.htm”>Read More…</a><br />
Here you go, it is an easy one.
the database:
-- phpMyAdmin SQL Dump
-- version 3.1.1
-- http://www.phpmyadmin.net
--
-- Vert: localhost
-- Generert den: 14. Mar, 2009 16:35 PM
-- Tjenerversjon: 5.1.30
-- PHP-Versjon: 5.2.8
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- Database: `toshow`
--
-- --------------------------------------------------------
--
-- Tabellstruktur for tabell `readmore`
--
CREATE TABLE IF NOT EXISTS `readmore` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`title` varchar(250) NOT NULL,
`beginningtext` varchar(250) NOT NULL,
`everything` varchar(9999) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
--
-- Dataark for tabell `readmore`
--
index.php
<?php
require 'db_connect.php';
$mysql = mysql_query("SELECT * FROM readmore ORDER BY id DESC") or die(mysql_error());
while($row = mysql_fetch_assoc($mysql)){
echo '<b>' . $row['title'] . '</b><br><br>';
echo $row['beginningtext'] . '<br>';
echo '<a href="news.php?id='.$row['id'].'">Read More</a><br><br>';
}
?>
db_connect.php
<?php
$dbhost = 'YOUR SQL HOST';
$dbusername = 'YOUR SQL USERNAME';
$dbpasswd = 'YOUR SQL PASSWORD';
$database_name = 'YOUR SQL DATABASE NAME';
$connection = mysql_connect("$dbhost","$dbusername","$dbpasswd")
or die ("Couldn't connect to server.");
$db = mysql_select_db("$database_name", $connection)
or die("Couldn't select database.");
?>
news.php
<?php
require 'db_connect.php';
$id = $_GET['id'];
$mysql = mysql_query("SELECT * FROM readmore WHERE id = '".$id."'") or die(mysql_error());
$row = mysql_fetch_assoc($mysql);
echo '<h2>' . $row['title'] . '</h2>';
echo '<b>' . $row['beginningtext'] . '</b><br><br>';
echo $row['everything'];
?>
add.php
<table>
<form action='addnews.php' method='post'>
<tr><td>Title</td><td>:</td><td><input type='text' id='title' name='title' /></td></tr>
<tr><td valign='top'>Beginning Text</td><td valign='top'>:</td><td><textarea id='post' name='beginningtext' rows='7'></textarea></td></tr>
<tr><td valign='top'>The Rest</td><td valign='top'>:</td><td><textarea id='post' name='everything' rows='7'></textarea></td></tr>
<tr><td> </td><td> </td><td><input type='submit' value='Post' /> <input type='reset' value='Reset' /></td></tr>
</form>
</table>
addnews.php
<?php
require 'db_connect.php';
if (mysql_query("INSERT INTO readmore (title,beginningtext,everything) VALUES ('".$_POST['title']."','".$_POST['beginningtext']."','".$_POST['everything']."')")) {
} else {
echo "Error!";
}
?>
To add a new, just go to “add.php”
*Note this is not a tutorial of any type.
Hm, that’s very useful, nice
Thanks, tookt me 10 minutes or so
But it doesn’t like show the 5 latest new, just so you are aware of it
But please, use it if you want to
Thank goodness I found this thread. I would’ve gone to all the time, trouble, effort and expense of putting the portion I didn’t want to appear, in a hidden ‘div’ and having it display, when the “Read more” link was clicked. This saves me from having to write four lines of code. Sorry, I couldn’t stop myself.:rolleyes:
You know what?
I am going to make some few changes and use it myself
BTW; No problem weishun
echo substr($text,0,350).'<a href="link">Read More</a>';
thanks for replying guys im sure it will be useful for others, despite it didn’t work for me:D
@JohnMark
Thanks for giving this code, but I have one question about this, can you explain about this code? I’m newbie for that code.
Sorry for my bad language.
echo substr($text,0,350).’<a href=“link”>Read More</a>’;
substr($text,0,350) would be displaying the first 351 characters of the string $text.
<a href=“link”>Read More</a> would be display the string 'Read More, and ‘link’ the link to the full text which is $text.
@bigal
Thank you… but still it didn’t work for me, btw I’m using website builder and paste the code that given, can u give me more clue on this? thanks…really appreciated
That wont work in the website builder, you have to code your code manually in php for it to work.
now i have more question then before…lol thank u Siz
I still didn’t know how to put this
echo substr($text,0,350).'<a href="link">Read More</a>';
I,m using dreamweaver btw, so could you please put more detail info on this. thanks
bump… I’m still waiting guys
if you’re new to html and stuff, the simplest would be a simple <a href="something>more</a>
or how bout using javascript to hide the text?
<html>
<head>
<script type="text/javascript">
/*<![CDATA[*/
function toggleMe(obj,a){
var e=document.getElementById(a),img=obj.getElementsByTagName('IMG')[0];
if(!e)return false;
if(e.style.display=="none"){
e.style.display="block";
} else {
e.style.display="none";
}
return false;
}/*]]>*/
</script>
</head>
<body>
<div id="isi2"><a href="#" onclick="return toggleMe(this,'isi3')" style="color:#ec008c"><p>[~]</a><strong><font size="2">Email dan Blog gratis</font></strong></p></div>
<div id="isi3" style="display:none">
<p align="justify">
Email anda terlalu biasa? kami menyediakan email gratis dengan basis server gmail, sehingga berkapasitas besar dan sangat aman. Alamat yang akan anda dapatkan adalah namaanda@pangaribuan.org.
</p><p align="justify">Kami juga menyediakan blog gratis berbasis wordpress beralamat di namabloganda.pangaribuan.org. </p>
<p align="justify"><b>Silahkan hubungi admin@pangaribuan.org.</b> <br>Kami akan memproses permintaan anda paling lambat 2x24 jam.
</p>
</div>
</body>
</html>