I built myself a little search feature. Not that complicated, and it seems to do the job alright, but I would like to add a little detail. The search results return the title and the entire article. I want to limit the article character count by 100 so I can get a nice list. (Please return modified code in full.) Thanks in advance!


<?php

if(isset($_GET['keyword'])){
$keyword = trim($_GET['keyword']) ;
$keyword = mysqli_real_escape_string($db, $keyword);

//query the db
$query = "select* from articles where article_title like '%$keyword%' or article_post like '%$keyword%' or tags like '%$keyword%'";

//echo $query;
$result = mysqli_query($db,$query);
if($result){
if(mysqli_affected_rows($dbc)!=0){
while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)){
echo '<p><h1 class="title"><a href="#">'.$row['article_title'].'</a></h1><br> '.$row['article_post'].'</p><br>' ;
}
}else {
echo 'No results for: "'.$_GET['keyword'].'"';
}
}
}else {
echo "";
}
?>