Beginner Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherBeginner Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 3rd, 2003, 11:27 AM
ur2kind ur2kind is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Los Angeles
Posts: 3 ur2kind User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question display format with php from mysql?

I have data in mysql that has new lines, ie.

line 1
line 2
line 3

all in one record. Is there a way I can use php to get and display each line separately?
Now I just get this: line1line2line 3

but I want this:
line1
line2
line3

Reply With Quote
  #2  
Old April 3rd, 2003, 12:05 PM
Ucht's Avatar
Ucht Ucht is offline
This is only a test
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Off the air
Posts: 2,893 Ucht User rank is First Lieutenant (10000 - 20000 Reputation Level)Ucht User rank is First Lieutenant (10000 - 20000 Reputation Level)Ucht User rank is First Lieutenant (10000 - 20000 Reputation Level)Ucht User rank is First Lieutenant (10000 - 20000 Reputation Level)Ucht User rank is First Lieutenant (10000 - 20000 Reputation Level)Ucht User rank is First Lieutenant (10000 - 20000 Reputation Level)Ucht User rank is First Lieutenant (10000 - 20000 Reputation Level)Ucht User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 5 Days 20 h 1 m 43 sec
Reputation Power: 147
Pull your query result into an array and arrange it from there:

PHP Code:
 $result = <whatever your query is>;

while(
$myrow =  mysql_fetch_array($result))
{   
    
$line1 $myrow["line1"];
    
$line2 $myrow["line2"];
    
$line3 $myrow["line3"];

echo 
"$line1<br>$line2<br>$line3";



Check out:
http://www.devshed.com/Server_Side/...01_4/page1.html

Reply With Quote
  #3  
Old April 3rd, 2003, 03:02 PM
ur2kind ur2kind is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Los Angeles
Posts: 3 ur2kind User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Sorry, I don't understand still. I have a table with: name varchar(50), comment blob, ID, primary key (ID). If a typical comment was like this:
Dear so and so,
I appreciate your help.
Please write back.

I used this as I thought you suggested:

$query = "SELECT * FROM $tableName";
$result = mysql_db_query($database, $query);
while ($myrow = mysql_fetch_array($result))
{
$name = $myrow['name'];
$line1 = $myrow['comment'];
$line2 = $myrow['comment'];
$line3 = $myrow['comment'];
$ID = $myrow['ID'];
echo "$line1<br>$line2<br>$line3";
}

but all I get is the whole comment three times:
Dear so and so, I appreciate your help. Please write back.
Dear so and so, I appreciate your help. Please write back.
Dear so and so, I appreciate your help. Please write back.

I checked mysql SELECT * from Table; and the format is still intact. I want to get the same carriage return after each sentence as I stored into the mysql record.

Reply With Quote
  #4  
Old April 3rd, 2003, 03:23 PM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,840 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 27 m 47 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
Take the affected lines and pass them through nl2br

i.e.
$text = nl2br($text);
echo $text;

Reply With Quote
  #5  
Old April 3rd, 2003, 03:40 PM
ur2kind ur2kind is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Los Angeles
Posts: 3 ur2kind User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks Onslaught, that did the trick.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherBeginner Programming > display format with php from mysql?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway