Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Heh, you're probably all going "Get a book already and stop bothering us!". Still haven't been anywhere to get a book, though I'm seriously hoping this'll be my last question for awhile. My problem is displaying data that I've gotten from my database. If I put in a value into my database like:
The dog is fast.
The dog likes to run.When I use something like:
$row = mysql_fetch_array($result)
echo "$row[dog][br]\n";To display that, it comes out as:
The dog is fast. The dog likes to run.
I took a look through the MySQL manual and didn't find anything that looked like it would output my lines correctly. I took a quick look through the PHP manual to see if there was anything, though I didn't find a function or anything that might do it. When I look at the data in phpMyAdmin it looks fine, but when it's printed to screen it comes out all weird like that. I must be missing something.
<><><>Tope<><><>

Please post your SQL-query and your database lay-out. What field-types are you using?
I assume your problem lies within the line-breaking?
Or are those lines seperate records in a table? (you dont mention that... ;-) ):
record 1: "The dog is fast."
record 2: "The dog likes to run."Or is it one record:
"
The dog is fast.
The dog likes to run.
"
with a line break?:-)

It's like the second thing you posted. I've tried putting a "\n" and also "\r\n" at the end of each of my lines, but that hasn't helped. When I add the data to the database the query goes something like this:
INSERT INTO `temp` (`name`, `stuff`) VALUES ('dog', 'The dog is fast.
The dog likes to run.');If I view that in phpMyAdmin it looks fine, but if I output it to the screen it doesn't come out on two lines, even though I put it in as two. The name column is tinytext and the stuff one is mediumtext, though I might being using largetext for it by the time I'm done. I'm not really sure what you mean by database layout.
<><><>Tope<><><>

If you look at the source code of the result page, you will probable see a line break. It is the html-parser (browser) that doesnt know that you want to use a
-tag.The html-code (= output query) looks like:
(without the " - s) (replace [] for <>)"The dog is fast.
The dog likes to run.[br]"But a browser handles this code as ONE paragraph and displays:
"The dog is fast. The dog likes to run.
"(notice the line break after 'run')
So if you want to display a record with text in a browser, dont forget to add the necessary html-code for the browser to handle. Otherwise the browser doesnt know what you mean.
For instance; replace the record with this code:
"[p]The dog is fast.[br]
The dog likes to run.[/p]"

Oh man. That was so simple. I had thought that if I put HTML tags in that they'd just come out as plain text. Thanks a lot!
<><><>Tope<><><>

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |