function showquestions($sub_id, $page, $currentpage, $newpage)
{
$query = "Select count(quest_id) from questions where sub_id = $sub_id";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
if ($row[0] == 0)
{
echo "<h2><br>Sorry, there are Questions in this category</h2>\n";
$query = "SELECT quest_id, question, LEFT(question, 115) AS first115 from questions WHERE sub_id=$sub_id ORDER BY question ASC LIMIT $offset,$recordsperpage";
$result = mysql_query($query);
while($row=mysql_fetch_array($result, MYSQL_ASSOC))
{
$quest_id = $row['quest_id'];
$question = $row['question'];
echo"<div id='content2'>";
$extract = $row['first115'];
// find position of last space in extract
$lastSpace = strrpos($extract, ' ');
// use $lastSpace to set length of new extract and add ...
echo substr($extract, 0, $lastSpace).'... ';
echo '<a href="details.php?quest_id='.$row['quest_id'].'"> More</a>';