|
-
Nov 2nd, 2001, 08:49 PM
#1
Thread Starter
Conquistador
Preserving formatting (mySQL and PHP)
Here's the go,
In a mysql database, i have stored code snippets.
however when i print out what is in the field (the code snippet field)
It prints out with no carriage returns, i.e.
Code:
'This code is for disabling resizing'Written by Matthew GatesOption Explicit
How do i fix that?
this is my current code
PHP Code:
$title = mysql_result ($result, 0, "title"); //Get the title
$type = mysql_result ($result, 0, "type");
$description = mysql_result ($result, 0, "description");
$code = mysql_result ($result, 0, "code");
echo "<center>$title</center><br>$vb<br>$description<br><br>$code";
-
Nov 2nd, 2001, 10:29 PM
#2
Thread Starter
Conquistador
Fixed that, new problem
I solved that with:
PHP Code:
$title = mysql_result ($result, 0, "title"); //Get the title
$type = mysql_result ($result, 0, "type");
$description = mysql_result ($result, 0, "description");
$code = nl2br(mysql_result ($result, 0, "code"));
echo "<center>$title</center><br>$vb<br>$description<br><br>$code";
Is there any way i can preserve tabs?
-
Nov 4th, 2001, 02:39 PM
#3
what is the field type in Mysql for that categorie? like varchar or something
-
Nov 4th, 2001, 06:45 PM
#4
Thread Starter
Conquistador
-
Nov 4th, 2001, 08:38 PM
#5
if it is text then I don't see why it won't. I use text and it does preserve the tabs and breaks. are you stripping the htmlcharacters from it?
-
Nov 4th, 2001, 08:43 PM
#6
Thread Starter
Conquistador
-
Nov 4th, 2001, 08:52 PM
#7
ahhh I know why. I put mine in a text area and you aren't. the reason you don't is becasue the browser doesn't let it. you should insert the htmlspecial characters into it. like exchange the break for a <br> and exchange the so many spaces & nbsp; and make it so many spaces.
I ran into this but decided to put the code in a textarea and make it readonly so I can keep the formatting.
-
Nov 4th, 2001, 08:54 PM
#8
Thread Starter
Conquistador
Thanks man, i'll try htmspecial'charring' it...
I wonder how John does it
-
Nov 4th, 2001, 08:58 PM
#9
Thread Starter
Conquistador
Have a look at it now, -> no such luck
Still preserves line spacing, but can't get proper tabs.
Myphpadmin can in a textbox
I got it working in a scrolling text box, but i wanted to color code it i'll see if John replies
-
Nov 4th, 2001, 11:18 PM
#10
yeah let me know, maybe he uses the <pre> tags. still let me know, might be something to keep in mind.
-
Nov 5th, 2001, 12:40 AM
#11
Thread Starter
Conquistador
Yeah that worked.
Thanks man
Now i just need to get the [vbcode ] formatting code off john...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|