[PHP] Parsing MySQL query return

2003-07-28 Thread John
Hey All,

I have a question regarding parsing text from a MySQL query. Basically, I
have several paragraphs of text in a field in MySQL. I run a query, get the
results, no problem. However, I would like to only display the first
paragraph of the data returned.

What is the best way to do this?

Thanks,
John




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Parsing MySQL query return

2003-07-28 Thread Ewout de Boer
- Original Message - 
From: John [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, July 28, 2003 8:22 PM
Subject: [PHP] Parsing MySQL query return


 Hey All,

 I have a question regarding parsing text from a MySQL query. Basically, I
 have several paragraphs of text in a field in MySQL. I run a query, get
the
 results, no problem. However, I would like to only display the first
 paragraph of the data returned.

 What is the best way to do this?

That depends on te format of the text/paragraphs in the mysql field.
How are the paragraphs separated ?



regards,
Ewout


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Parsing MySQL query return

2003-07-28 Thread John
I'm using someone elses data here (inheriting). But it looks like it was
typed into the field, possibly using PHPMyADMIN. I would assume the
paragraphs are just seperated by carriage returns. Is there a way to tell
for sure?

John


Ewout De Boer [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 - Original Message - 
 From: John [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Monday, July 28, 2003 8:22 PM
 Subject: [PHP] Parsing MySQL query return


  Hey All,
 
  I have a question regarding parsing text from a MySQL query. Basically,
I
  have several paragraphs of text in a field in MySQL. I run a query, get
 the
  results, no problem. However, I would like to only display the first
  paragraph of the data returned.
 
  What is the best way to do this?

 That depends on te format of the text/paragraphs in the mysql field.
 How are the paragraphs separated ?



 regards,
 Ewout




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Parsing MySQL query return

2003-07-28 Thread Nicholas Robinson
If you assume either \n or \n\n as the para delimiters then you could use 
strpos (see function.strpos.html)  to work out where to split the text. If the 
text field contents are huge, you might consider limiting the query results 
by using left( field, size ) in the query.

KR

N
On Monday 28 Jul 2003 7:57 pm, Ewout de Boer wrote:
 - Original Message -
 From: John [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Monday, July 28, 2003 8:22 PM
 Subject: [PHP] Parsing MySQL query return

  Hey All,
 
  I have a question regarding parsing text from a MySQL query. Basically, I
  have several paragraphs of text in a field in MySQL. I run a query, get

 the

  results, no problem. However, I would like to only display the first
  paragraph of the data returned.
 
  What is the best way to do this?

 That depends on te format of the text/paragraphs in the mysql field.
 How are the paragraphs separated ?



 regards,
 Ewout


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Parsing MySQL query return

2003-07-28 Thread Nicholas Robinson
It occurred to me after my first reply that you might be able to do something 
in mysql.

This works (given my earlier assumptions):

select left( paras, if ( locate( '\n', paras ) = 0, length( paras ), locate( 
'\n', paras ))) ...

It will work with \n\n as well.

N
On Monday 28 Jul 2003 7:57 pm, Ewout de Boer wrote:
 - Original Message -
 From: John [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Monday, July 28, 2003 8:22 PM
 Subject: [PHP] Parsing MySQL query return

  Hey All,
 
  I have a question regarding parsing text from a MySQL query. Basically, I
  have several paragraphs of text in a field in MySQL. I run a query, get

 the

  results, no problem. However, I would like to only display the first
  paragraph of the data returned.
 
  What is the best way to do this?

 That depends on te format of the text/paragraphs in the mysql field.
 How are the paragraphs separated ?



 regards,
 Ewout


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Parsing MySQL query return

2003-07-28 Thread Jason Wong
On Tuesday 29 July 2003 04:16, John wrote:
 I'm using someone elses data here (inheriting). But it looks like it was
 typed into the field, possibly using PHPMyADMIN. I would assume the
 paragraphs are just seperated by carriage returns. Is there a way to tell
 for sure?

Yes, examine the contents.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
I don't want to be young again, I just don't want to get any older.
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php