Selecting a row where nth character is

I have a html page where the space available has to contain a limit of
characters (including spaces) .
Therefore i need to select all rows which add up to a certain number of characters.
Trouble is i don’t want to display a partial record.I want all rows to be complete when displayed on my html page.
How do i go about finding the row where that nth character is located and how do i display all the rows previous to this one if the nth character isn’t the cutoff point for that row!!?

Thread can be found here:

This thread is now closed.

Ok thanks everyone -ill post a new thread in the php section instead.:slight_smile:

You can’t do that in MySQL. It’s something you’ll have to do in PHP.

There are no create table statements in my code.I am only creating an unordered list in a div box.

I think rudy was asking you to show your create table statements. without them, it’s very difficult to help you.

what you have described is entirely a php problem and has nothing to do with mysql

The html is non important in this case- the results are also in divs not tables.

… (“SELECT name,age,description FROM life”);

while(list($variable1,$variable2,$variable3)= mysql_fetch_row($result))
echo “<li><b>$variable1</b><em>$variable2</em><br/> <br/>$variable3</li>”;…

This is the main part of retrieving the results.
Imagine the 1st row has “Janice33Blue eyed blonde from London Who’s interests are skiing.” The number of characters is 66 in total adding together the name,age and description.
I continue counting all the characters in row2,row3,row4 and so on until i eventually reach character 3000.Let’s say it occurs in row 30.
Now if the character is row 30’s last character- then i have 30 complete rows no problem to fetch and echo with the while statement.
If the 3000th character is not row 30’s last character then i want the while statement to print 29 rows instead.This makes sure the html page only shows complete records -not cutting them off at the bottom of the page.

Sorry i’m being misunderstood here or not very clear. :smiley:
I need a mysql statement that can select all the rows that add up to 3000th characters and go back to the previous row if its not at the end of that final row.

you’re probably going to have to show us (1) your html page, and (2) your table design

as it stands, your question doesn’t make a lot of sense, sorry