# \[MySQL\] SELECT title SUBSTRING

**URL:** https://forum.kirupa.com/t/mysql-select-title-substring/80137
**Category:** Uncategorized
**Created:** [February 19, 2005, 7:59pm UTC](https://forum.kirupa.com/t/mysql-select-title-substring/80137 "2005-02-19T19:59:50Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![four1seven](https://avatars.discourse-cdn.com/v4/letter/f/d78d45/32.png) [@four1seven](https://forum.kirupa.com/u/four1seven)
#### Post date: [February 19, 2005, 7:59pm UTC](https://forum.kirupa.com/t/mysql-select-title-substring/80137/1 "2005-02-19T19:59:50Z")

</div>

Hey guys (and gals),

I am having a good time with this one…

I cannot get it to return only the first 15 characters of the title. What am I doing wrong?

This is pretty much my first time coding PHP and MySQL, so it may be a input error but what seems to be the deal?

```php

<?
require_once('inc/mysqlconnect.inc');
@mysql_select_db("database"); 
//$sql = 'SELECT title FROM blog_entry ORDER BY date DESC LIMIT 0, 8';
//$sql = 'SELECT *, LEFT(title, 14) FROM blog_entry ORDER BY date DESC LIMIT 0, 8';
$sql = 'SELECT title, SUBSTRING(title, 15) FROM blog_entry ORDER BY date DESC LIMIT 0, 8'; 
//$sql = 'SELECT substring(title, 1, round(char_length(title) * 0.70) ) FROM `blog_entry` ORDER BY entryNo DESC LIMIT 0, 10';
$result = mysql_query($sql) or die(mysql_error()); 
if(mysql_num_rows($result)!= 0)
{ 
while($row = mysql_fetch_array($result))
{
echo "<b>+</b>&nbsp;<a href=\"link.php\">$row[6]</a><br />";
}
echo "</p>";
} 
?>

```

As you can see thers several ways I tried doing it…but it’s not working ☹

Thanks for any help!

Joel
