Hi there guys,
I'm trying to create a block to show a random result for a testimonial script I am writing, and I've got the random result working a-ok, but I have a problem:
For both the title and testimonial content, I need to limit the result so if something is way too long, it won't stretch the block to a size that messes up the page.
The title seems straight forward, but the testimonial body will be tougher to do. I allow URL's and simple html like bold, italicize, etc.
How can I:
1) do a simple limitation of the title
&
2) limit the testimonial body, but let the script know that it's not to break html, i.e. either allow the result to continue until it gets to the ending tag, or stops early so it doesn't get a start tag in HTML if the character limitation won't allow it to get to the end tag. Would it be much better just to strip the tags completely?
Here's my current DB call:
$query = "select * from testimonials WHERE active=1 ORDER BY rand() LIMIT 1";
$result = mysql_query ($query);
while ($row = mysql_fetch_assoc ($result)) {
/* display testimonials in a simple table */
$date = $row['date'];
$author = stripslashes ($row['author']);
$title = stripslashes ($row['title']);
$testtext = stripslashes ($row['testtext']);
From that, how would I limit the title to 25 characters, and the testtext to 100?
thanks for your time,
json