Computing.Net > Forums > Web Development > Trouble displaying MySQL

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Trouble displaying MySQL

Reply to Message Icon

Name: Tope
Date: April 26, 2004 at 15:14:15 Pacific
OS: WinXP
CPU/Ram: 2.53gHZ/512RAM
Comment:

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<><><>



Sponsored Link
Ads by Google

Response Number 1
Name: Khalid
Date: April 26, 2004 at 22:15:33 Pacific
Reply:

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?

:-)


0

Response Number 2
Name: Tope
Date: April 26, 2004 at 23:50:46 Pacific
Reply:

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<><><>


0

Response Number 3
Name: Khalid
Date: April 27, 2004 at 02:42:12 Pacific
Reply:

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]"


0

Response Number 4
Name: Tope
Date: April 27, 2004 at 10:56:00 Pacific
Reply:

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<><><>


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: Trouble displaying MySQL

internet conn. slow since apache www.computing.net/answers/webdevel/internet-conn-slow-since-apache/1649.html

ASP.NET and PHP www.computing.net/answers/webdevel/aspnet-and-php/2833.html

Downloading a file from mysql www.computing.net/answers/webdevel/downloading-a-file-from-mysql/2373.html