Skrip/Code PHP: Readmore dengan substr
code database echo explode fungsi kode koding pemrograman PHP program skrip sustr while
<?php
include"koneksiphp.php";
if(isset($_GET['id'])){
$id=$_GET['id'];
$query="SELECT
* FROM berita WHERE id='$id'";
$hasil=mysql_query($query)
or die("gagal");
while($data=mysql_fetch_array($hasil)){
echo
$data['judul']."<br>";
echo
str_replace("<>","",$data['isi']);
}
} else {
$query="SELECT
* FROM berita";
$hasil=mysql_query($query);
while($data=mysql_fetch_array($hasil)){
echo
$data['judul']. "<br>";
$artikel=$data['isi'];
echo
substr($artikel,0,400). "<br>";
echo
"<a href=readmore2.php?id=$data[id]>readmore</a>";
echo
"<hr>";
}
}
?>