Tech Talk Discuss PC Hardware, Software, Internet and Other Technology

PHP/mySQL content entry question.

Old 05-07-04, 12:28 PM
  #1  
DVD Talk Platinum Edition
Thread Starter
 
Join Date: Dec 2002
Location: NJ
Posts: 3,337
PHP/mySQL content entry question.

So I am making a fairly basic content management system for a new site that I am working on. I built out the skeleton of the backend last night and built the online editing and adding capabilities. I have on thing that I need to modify though.

Basically I have the meat of the content being put into one row of the table in the DB. I will call that the "article" for now. I want to make it so that when you are entering in a new article (or even for editing existing ones) that when you hit a carriage return in the text box it will automatically translate that into
Code:
< br >< br >
in the database so that it displays the content correctly when it is called up on the page.

I know that we have done something similar at my work on some ASP and CF surveys working with SQL server. Unfortunately the programmer who worked on them is not in today and I can't pick their brain. Anyone have an ideas? I would guess something in PHP would be best, but if it is a javascript that would work as well.

Thanks!
fnordboy is offline  
Old 05-07-04, 01:28 PM
  #2  
DVD Talk Special Edition
 
Join Date: Sep 1999
Location: Bristol, CT USA
Posts: 1,861
I can't help much, but it would be much more correct html to surround the paragraph with <p&gt&lt/p> tags.

I bet you could use a regular expression to search out the "\n\n" and replace it with the aforementioned tags, though.
danw is offline  
Old 05-07-04, 01:32 PM
  #3  
DVD Talk Platinum Edition
Thread Starter
 
Join Date: Dec 2002
Location: NJ
Posts: 3,337
Originally posted by danw
I can't help much, but it would be much more correct html to surround the paragraph with <p&gt&lt/p> tags.

I bet you could use a regular expression to search out the "\n\n" and replace it with the aforementioned tags, though.
YEs, it would be more correct, but I would think as a whole it would be quicker to just code it with the two breaks.
fnordboy is offline  
Old 05-07-04, 03:13 PM
  #4  
DVD Talk Legend
 
Join Date: Oct 1999
Location: Plano, TX
Posts: 23,226
Code:
$anime_sucks=str_replace("\n","&ltbr&gt",$anime_sucks);
PixyJunket is offline  
Old 05-07-04, 03:34 PM
  #5  
DVD Talk Platinum Edition
Thread Starter
 
Join Date: Dec 2002
Location: NJ
Posts: 3,337
That made me cry

Big meanie
fnordboy is offline  
Old 05-07-04, 03:58 PM
  #6  
DVD Talk Legend
 
Join Date: Oct 1999
Location: Plano, TX
Posts: 23,226
I was being silly willy!!!

It works, doesn't it?

That's what I use on all my PHP/mySQL sites.
PixyJunket is offline  
Old 05-07-04, 04:09 PM
  #7  
DVD Talk Platinum Edition
Thread Starter
 
Join Date: Dec 2002
Location: NJ
Posts: 3,337
Originally posted by PixyJunket
I was being silly willy!!!

It works, doesn't it?

That's what I use on all my PHP/mySQL sites.
I haven't tried it yet since I am at work (the site is my own project) and I am just too busy with DVDTalk work, to try it out until tonight.

Looks, like it will work fine though actually. SO easy that I am kicking myself. Thanks (you big meanie!)
fnordboy is offline  
Old 05-07-04, 04:44 PM
  #8  
DVD Talk Special Edition
 
Join Date: Sep 1999
Location: Bristol, CT USA
Posts: 1,861
Again, in the name of correct HTML, how about:
PHP Code:
$anime_sucks=str_replace("\n""</p><p>"$anime_sucks); 
And be sure to wrap $anime_sucks like this:
PHP Code:
echo "<p> $anime_sucks </p> 
danw is offline  
Old 05-08-04, 09:05 AM
  #9  
DVD Talk Platinum Edition
Thread Starter
 
Join Date: Dec 2002
Location: NJ
Posts: 3,337
Ok danw you win I am going to try this out now actually since I got busy last night with other crap. Thanks guys.
fnordboy is offline  
Old 05-08-04, 09:31 AM
  #10  
DVD Talk Platinum Edition
Thread Starter
 
Join Date: Dec 2002
Location: NJ
Posts: 3,337
Ok, worked like a charm. Thanks guys (even you PixyJunket [ shakes fist ] ).
fnordboy is offline  

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Thread Tools
Search this Thread

Archive Advertising Cookie Policy Privacy Statement Terms of Service

Copyright 2018 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.