Search the Community
Showing results for tags 'child'.
-
This is my database structure: http://www.awesomescreenshot.com/image/733881/57d01b042ca99b9a36dde90dd6640cdc I would like to loop through all the child elements (those who's parent_id is set to the data_id within the same table). Therefore those with "parent_id" as "0" are parents, and those with parent_id with a number in it is a child. I would like help creating a function that will generate tables, with the table itself as the parent, and all the rows within it would be children of that parent. There is only one layer of depth in this project (one parent and one child layer always. ). Can anyone help, or would want a more detailed description? Thank you, and looking forward to a reply.
-
I am trying to get the names of the children nodes in XML Here is the code: foreach ($pos->children() as $child) { echo "I never get here"; echo $child->getName() . "\n"; } //} echo "but the node has children---<br>"; print_r($pos); which I modeled on the code from http://www.php.net/manual/en/simplexmlelement.getname.php and here is a sample of the output: SimpleXMLElement Object ( [n] => SimpleXMLElement Object ( ) ) but the node has children--- SimpleXMLElement Object ( [int] => SimpleXMLElement Object ( ) ) but the node has children--- SimpleXMLElement Object ( [n] => SimpleXMLElement Object ( ) ) Why can't I go through the chldren with foreach?
-
So I'm stuck on an issue while parsing a forum, I want to ignore the quotes and only read the message from the posted user. So .. Imagine I have this HTML loaded. <div class="main"> <div class="quote"> Some stuff written here .. </div> More written here and a <b>bold word</b> or two. </div>So, what I want to return is: More written here and a bold word or two.Which is returned when I evaluate the path, but it also returns what's in the quote and I ain't sure how to ignore that. Using /text() will ignore the bolded words in this example. Thanks for any help.
-
Hi there! I am currently trying to edit a wordpress theme, and with my limited knowledge, I got stuck first thing., I have just added a subpage to a page on my blog for the first time, and would love to display a list in the sidebar on the parent that displays the parent itself, and all children. On the childpages, this same list (parent+children) should be visible. So, let's say I have a page called: contact, with subpages like 'route' and 'form', it should look like this, on the parentpage (contact) and the children: Contact Route Form On pages that do not have children, there should be no list. Looking through the wordpress codex, I found the following code to add to my sidebar.php: <?php //if the post has a parent if($post->post_parent){ //collect ancestor pages $relations = get_post_ancestors($post->ID); //get child pages $result = $wpdb->get_results( "SELECT ID FROM wp_posts WHERE post_parent = $post->ID AND post_type='page'" ); if ($result){ foreach($result as $pageID){ array_push($relations, $pageID->ID); } } //add current post to pages array_push($relations, $post->ID); //get comma delimited list of children and parents and self $relations_string = implode(",",$relations); //use include to list only the collected pages. $sidelinks = wp_list_pages("title_li=&echo=0&include=".$relations_string); }else{ // display only main level and children $sidelinks = wp_list_pages("title_li=&echo=0&depth=1&child_of=".$post->ID); } if ($sidelinks) { ?> <h2><?php the_title(); ?></h2> <ul> <?php //links in <li> tags echo $sidelinks; ?> </ul> <?php } ?> This works perfect on a child page, displaying child and parent in a neat linkable list. But on the parent page it only displays the child. How can I also add the parent there? Thank you in advance for your help!