want to add a break after a certain amount of characters


Posted on 16th Feb 2014 07:03 pm by admin

i was wondering how to add a break in a blog post after a certain amount of characters... any idea on how to do this???

this is the code i'm workig with

<?php

$connect = mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("blog", $connect) or die(mysql_error());

echo "<h1>Blog</h1>";

$query = mysql_query("SELECT * FROM blog");

if (mysql_num_rows($query) == 0) {
echo "<hr />There are no posts yet, make the first in the admin section!";
} else {
while ($row = mysql_fetch_assoc($query)) {
echo "<hr />";
$title2 = $row['title'];
$name = $row['name'];
$email = $row['email'];
$post = $row['post'];
$date = $row['date'];
$time = $row['time'];

echo "<h3>Title: " . $title2 . "</h3><table width='100%'><tr><td><b>Posted by: " . $name . "(" . $email . ") at " . $time . " on " . $date . "</b></td></tr><tr><td>" . nl2br(strip_tags($post)) . "</td></tr></table>n";
}
}

echo "<hr />";

$page = $_GET['p'];
if ($page) {
$path = "/inc/" . $page . ".php";
if (file_exists($path)) {
include ($path);
}
}

echo "Are you an admin? <a href='index.php?p=blog&p=credentials'>Place a post</a>";

?>

No comments posted yet

Your Answer:

Login to answer
117 Like 36 Dislike
Previous forums Next forums
Other forums

php require help needed
Ok i tried to use the search funtion but the word require is everywhere.

i'm really new to cr

validating url
im trying to validate url's sent to me by a form
the url's im collecting are for placing banners

User feedback after MySQL query has been executed
Hi all, I've just registered on PHPFreaks because I've got a question that I simply can't work out b

What do you call the "token" thing?
You know how some sites have links that run on tokens? Tokens are links that only stay alive for a c

PHP mail() rejected by SMTP
I'm currently working on a newsletter application which is installed on a windows 2003 server runnin

Preserving user-entered linebreaks
Hi, I'm building a web 2.0 thingy from scratch and I wanna display text which users input. It's all

Add 5 to a variable when a button is clicked, and re-run a for loop
So I'm making a feedback sort of section on a website with MySQL and PHP, I've gotten the script to

do while...woes
I'm sure this is childsplay but it is stumping me, everytime i try what I think would make this work

trouble printing an array....
I'm having some trouble printing out an array forwards. I'm figuring out the high and low of an arra

I face problems to extract data from one table and insert it in another one
Hi,

For modifications, I have to extract data from one table and insert it in another one

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash