Can you return only so many characters from a mysql query?
Posted: Thu Apr 10, 2008 9:04 pm
I'm getting ready to venture further into PHP territory by attempting to set up a way for users of my site to create a new item on the front page by "linking" to one of their forum posts. The way that I was thinking of setting this up was letting them create their post first, then choosing an option to create an item on the front page. What I would want to happen next is for the first so-many characters from their post be copied into another table that will be called by the main page. But obviously, if they create a very large post, I don't want my entire front page be cluttered with text after text.
For example, let's say someone wants to post their thoughts on the current Democratic primaries, and they insisted on typing up a 3000-word opinion piece. If they wanted to display this on the front page, I would only want to call, say, the first 300 or 400 characters of that post to display, then I would create a link back to their forum post for someone to read further.
I haven't started piecing this together yet, partly due to lack of time and partly due to nervousness of doing something on this scale (this would be a big project for a person of my skill level). So, before I actually start, I think this truncating of their post is the only thing that I'm not quite sure how to do. Can anyone get me started by giving me a function to research, or a couple of lines of code as an example of how to truncate a post that I've called out of mySQL?
I appreciate any advice.
For example, let's say someone wants to post their thoughts on the current Democratic primaries, and they insisted on typing up a 3000-word opinion piece. If they wanted to display this on the front page, I would only want to call, say, the first 300 or 400 characters of that post to display, then I would create a link back to their forum post for someone to read further.
I haven't started piecing this together yet, partly due to lack of time and partly due to nervousness of doing something on this scale (this would be a big project for a person of my skill level). So, before I actually start, I think this truncating of their post is the only thing that I'm not quite sure how to do. Can anyone get me started by giving me a function to research, or a couple of lines of code as an example of how to truncate a post that I've called out of mySQL?
I appreciate any advice.