Jump to content

When inserting allot of text into a record breaks are not showing


son.of.the.morning

Recommended Posts

invoking the class

$values = array("$title","$img","$post","$aurthor_id","$category_id","$date_posted");
$fields = array('title,','img,','post,','aurthor_id,','category_id,','date_posted'); 
$obj= new DatabaseInsert;
$obj->DatabaseConnectionRequire();
$obj->ArticleInsert($values,$fields,$table); 

 

The Insert Class

class DatabaseInsert {

	function DatabaseConnectionRequire() {
		include("../scrips/php/database.connection.class.php");
		include("../scrips/php/database.settings.php");	
		include("../scrips/php/database.connection.class.invoke.php");	

	}

	function ArticleInsert($values,$fields,$table) {

		$values_imploded = implode("   ",$values);
		$fields_imploded = implode("   ",$fields);
		$i = "INSERT INTO $table ($fields_imploded) VALUES ($values_imploded)";
		//mysql_query($i) or die (mysql_error());
		//Uncomment ^ this to check the query for errors.

		if (!(mysql_query($i))) {

	    	echo "Sorry, something whent wrong there...";
		}

		else {
			echo "<strong><p style='color:green;'>Content added sucessfully!!!</p></strong>";
		}

	}
}

 

The View point

if(isset($_GET['id'])) {
// Get the id and select it's corresponding record 
$id = $_GET['id']; 
$query = "SELECT * FROM blog_posts  INNER JOIN post_categories ON blog_posts.category_id=post_categories.id WHERE blog_posts.id = $id";
$get_results = mysql_query($query) or die (mysql_error());
$results = mysql_fetch_array($get_results);
}

<?php echo $results['post']; ?> // the main body of the article

 

Link to comment
Share on other sites

I use a text area. When i check the post inside my database it shows paragraphs but when i try echo that record column out it doesn't show the paragraphs it just shows one big chunk of text. 

 

          	<div id="ArticleBody" style="font-size:13px; font-size: 13px; margin-top: 26px; width: 729px;">
                          <?php echo bbcode($results['post']); ?>
               </div>

Link to comment
Share on other sites

Winstons's solution is correct, of course. But in order to you know - you don't have to use this function nl2br() in 2 cases:

//if you show this text again in textarea, maybe in any form, for editing
echo '<textares>'.$results['post'].'</textarea>';

// or as I said earlier - you just send it to browser with PRE tags and browser show it correctly
echo '<pre>'.$results['post'].'</pre>';

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.