RE: Query or solution pls..

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Why not make it easier on yourself and simply normalize the database with
parent/child codes? 
It's dead easy and then all you need to do is loop through the results to
get your headings and the content underneath.

-----Original Message-----
From: php-objects@xxxxxxxxxxxxxxx [mailto:php-objects@xxxxxxxxxxxxxxx] On
Behalf Of Rajesh Kumar
Sent: Thursday, July 20, 2006 9:22 AM
To: php-objects@xxxxxxxxxxxxxxx
Subject: Re:  Query or solution pls..

Prathap kumar wrote:

> Hello everyone, I am trying to make "table of content" to my content in
the web page.The content in the database table field look like this.
> 
> Heading
> ..........
> ..........
> <h3>1. sub heading</h3>
> .............
> .............
> <h3>2. sub heading</h3>
> .............
> .............
> 
> Format of Table of Content Box/table with hyperlinks 1. sub heading 1 
> 2. sub heading 2
> 
> My question is how can I get only sub headings which are in between 
> "<h3>.....</h3>" in the database field. Is it possible with "select 
> query" or preg_replace_callback,,

This should do it.

<?php

// store data from database field here
$data = '';

preg_match_all('/<h3>(.*)<\/h3>/Ui', $data, $matches);

foreach ($matches[1] as $val) {
     echo $val . "\n";
}

?>


--
Rajesh



PHP Data object relational mapping generator
http://www.metastorage.net/ 
Yahoo! Groups Links



 








------------------------ Yahoo! Groups Sponsor --------------------~--> 
Check out the new improvements in Yahoo! Groups email.
http://us.click.yahoo.com/6pRQfA/fOaOAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

PHP Data object relational mapping generator
http://www.metastorage.net/ 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-objects/

<*> To unsubscribe from this group, send an email to:
    php-objects-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux